mirror of
https://gitlab.com/bztsrc/posix-uefi.git
synced 2025-01-01 03:25:52 +01:00
Make sure returned address is NULL on error
This commit is contained in:
parent
61758230ba
commit
e90f4a44bc
1 changed files with 3 additions and 3 deletions
|
@ -76,7 +76,7 @@ void *malloc (size_t __size)
|
||||||
{
|
{
|
||||||
void *ret = NULL;
|
void *ret = NULL;
|
||||||
efi_status_t status = BS->AllocatePool(LIP ? LIP->ImageDataType : EfiLoaderData, __size, &ret);
|
efi_status_t status = BS->AllocatePool(LIP ? LIP->ImageDataType : EfiLoaderData, __size, &ret);
|
||||||
if(!EFI_ERROR(status) || !ret) errno = ENOMEM;
|
if(EFI_ERROR(status) || !ret) { errno = ENOMEM; ret = NULL; }
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ void *realloc (void *__ptr, size_t __size)
|
||||||
void *ret = __ptr;
|
void *ret = __ptr;
|
||||||
/* not sure if this works */
|
/* not sure if this works */
|
||||||
efi_status_t status = BS->AllocatePool(LIP ? LIP->ImageDataType : EfiLoaderData, __size, &ret);
|
efi_status_t status = BS->AllocatePool(LIP ? LIP->ImageDataType : EfiLoaderData, __size, &ret);
|
||||||
if(!EFI_ERROR(status) || !ret) errno = ENOMEM;
|
if(EFI_ERROR(status) || !ret) { errno = ENOMEM; ret = NULL; }
|
||||||
return ret;
|
return ret;
|
||||||
#else
|
#else
|
||||||
void *ret = malloc(__size);
|
void *ret = malloc(__size);
|
||||||
|
@ -107,7 +107,7 @@ void *realloc (void *__ptr, size_t __size)
|
||||||
void free (void *__ptr)
|
void free (void *__ptr)
|
||||||
{
|
{
|
||||||
efi_status_t status = BS->FreePool(__ptr);
|
efi_status_t status = BS->FreePool(__ptr);
|
||||||
if(!EFI_ERROR(status)) errno = ENOMEM;
|
if(EFI_ERROR(status)) errno = ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
void abort ()
|
void abort ()
|
||||||
|
|
Loading…
Reference in a new issue