if (!line_in)
line_in = L"";
+
size = StrLen(line_in) + 1024;
line = AllocatePool(size * sizeof(CHAR16));
+ if (!line)
+ return FALSE;
+
StrCpy(line, line_in);
len = StrLen(line);
print = AllocatePool((x_max+1) * sizeof(CHAR16));
+ if (!print)
+ return FALSE;
first = 0;
cursor = 0;
/* Put status line after the entry list, but give it some breathing room. */
y_status = MIN(y_start + MIN(visible_max, config->entry_count) + 4, y_max - 1);
- strv_free(lines);
- FreePool(clearline);
+ lines = strv_free(lines);
+ clearline = mfree(clearline);
/* menu entries title lines */
lines = AllocatePool((config->entry_count + 1) * sizeof(CHAR16 *));
+ if (!lines) {
+ log_oom();
+ return FALSE;
+ }
+
for (UINTN i = 0; i < config->entry_count; i++) {
UINTN j, padding;
lines[i] = AllocatePool(((line_width + 1) * sizeof(CHAR16)));
+ if (!lines[i]) {
+ log_oom();
+ return FALSE;
+ }
+
padding = (line_width - MIN(StrLen(config->entries[i]->title_show), line_width)) / 2;
for (j = 0; j < padding; j++)
lines[config->entry_count] = NULL;
clearline = AllocatePool((x_max+1) * sizeof(CHAR16));
+ if (!clearline) {
+ log_oom();
+ return FALSE;
+ }
+
for (UINTN i = 0; i < x_max; i++)
clearline[i] = ' ';
clearline[x_max] = 0;
UINTN file_size;
assert(this);
- assert(device_path_const);
if (!device_path_const)
return EFI_INVALID_PARAMETER;
dev_path = DuplicateDevicePath((EFI_DEVICE_PATH*) device_path_const);
+ if (!dev_path)
+ return EFI_OUT_OF_RESOURCES;
status = uefi_call_wrapper(BS->LocateDevicePath, 3, (EFI_GUID*) SIMPLE_FS_GUID, &dev_path, &h);
if (status != EFI_SUCCESS)
/* No need to check return value, this already happened in efi_main() */
root = LibOpenRoot(h);
dev_path_str = DevicePathToStr(dev_path);
+ if (!dev_path_str)
+ return EFI_OUT_OF_RESOURCES;
status = file_read(root, dev_path_str, 0, 0, &file_buffer, &file_size);
if (EFI_ERROR(status))
_cleanup_freepool_ CHAR16 *s = NULL;
s = DevicePathToStr(loaded_image->FilePath);
- efivar_set(LOADER_GUID, L"LoaderImageIdentifier", s, 0);
+ if (s)
+ efivar_set(LOADER_GUID, L"LoaderImageIdentifier", s, 0);
+ else
+ log_oom();
}
/* if LoaderFirmwareInfo is not set, let's set it */
_cleanup_freepool_ CHAR16 *s = NULL;
s = PoolPrint(L"%s %d.%02d", ST->FirmwareVendor, ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0xffff);
- efivar_set(LOADER_GUID, L"LoaderFirmwareInfo", s, 0);
+ if (s)
+ efivar_set(LOADER_GUID, L"LoaderFirmwareInfo", s, 0);
+ else
+ log_oom();
}
/* ditto for LoaderFirmwareType */
_cleanup_freepool_ CHAR16 *s = NULL;
s = PoolPrint(L"UEFI %d.%02d", ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0xffff);
- efivar_set(LOADER_GUID, L"LoaderFirmwareType", s, 0);
+ if (s)
+ efivar_set(LOADER_GUID, L"LoaderFirmwareType", s, 0);
+ else
+ log_oom();
}
/* add StubInfo */
options = (CHAR16 *)loaded_image->LoadOptions;
cmdline_len = (loaded_image->LoadOptionsSize / sizeof(CHAR16)) * sizeof(CHAR8);
line = AllocatePool(cmdline_len);
+ if (!line)
+ return log_oom();
+
for (UINTN i = 0; i < cmdline_len; i++)
line[i] = options[i];
cmdline = line;
len = strlena(stra);
str = AllocatePool((len + 1) * sizeof(CHAR16));
+ if (!str)
+ return NULL;
strlen = 0;
i = 0;
len = strlena(stra);
str = AllocatePool((len + 2) * sizeof(CHAR16));
+ if (!str)
+ return NULL;
str[0] = '\\';
strlen = 1;