summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
ae9026d)
The AllocateCopyPool in function ExtractFileNameFromDevicePath
may return NULL, so need to do error handling. This patch is to
add error handling codes for function ExtractFileNameFromDevicePath
and its caller functions.
Cc: Eric Dong <eric.dong@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
String = UiDevicePathToStr(DevicePath);\r
MatchString = String;\r
LastMatch = String;\r
String = UiDevicePathToStr(DevicePath);\r
MatchString = String;\r
LastMatch = String;\r
\r
while(MatchString != NULL){\r
LastMatch = MatchString + 1;\r
\r
while(MatchString != NULL){\r
LastMatch = MatchString + 1;\r
\r
Length = StrLen(LastMatch);\r
FileName = AllocateCopyPool ((Length + 1) * sizeof(CHAR16), LastMatch);\r
\r
Length = StrLen(LastMatch);\r
FileName = AllocateCopyPool ((Length + 1) * sizeof(CHAR16), LastMatch);\r
- *(FileName + Length) = 0;\r
+ if (FileName != NULL) {\r
+ *(FileName + Length) = 0;\r
+ }\r
\r
FreePool(String);\r
\r
\r
FreePool(String);\r
\r
EFI_BOOT_MANAGER_LOAD_OPTION BootOption;\r
CHAR16 *FileName;\r
\r
EFI_BOOT_MANAGER_LOAD_OPTION BootOption;\r
CHAR16 *FileName;\r
\r
FileName = ExtractFileNameFromDevicePath(FilePath);\r
FileName = ExtractFileNameFromDevicePath(FilePath);\r
- EfiBootManagerInitializeLoadOption (\r
- &BootOption,\r
- 0,\r
- LoadOptionTypeBoot,\r
- LOAD_OPTION_ACTIVE,\r
- FileName,\r
- FilePath,\r
- NULL,\r
- 0\r
- );\r
- //\r
- // Since current no boot from removable media directly is allowed */\r
- //\r
- gST->ConOut->ClearScreen (gST->ConOut);\r
+ if (FileName != NULL) {\r
+ EfiBootManagerInitializeLoadOption (\r
+ &BootOption,\r
+ 0,\r
+ LoadOptionTypeBoot,\r
+ LOAD_OPTION_ACTIVE,\r
+ FileName,\r
+ FilePath,\r
+ NULL,\r
+ 0\r
+ );\r
+ //\r
+ // Since current no boot from removable media directly is allowed */\r
+ //\r
+ gST->ConOut->ClearScreen (gST->ConOut);\r
- BmmSetConsoleMode (FALSE);\r
- EfiBootManagerBoot (&BootOption);\r
- BmmSetConsoleMode (TRUE);\r
+ BmmSetConsoleMode (FALSE);\r
+ EfiBootManagerBoot (&BootOption);\r
+ BmmSetConsoleMode (TRUE);\r
- EfiBootManagerFreeLoadOption (&BootOption);\r
+ EfiBootManagerFreeLoadOption (&BootOption);\r
+ }\r
/** @file\r
Dynamically update the pages.\r
\r
/** @file\r
Dynamically update the pages.\r
\r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
CHAR16 *String;\r
EFI_STRING_ID StringToken;\r
\r
CHAR16 *String;\r
EFI_STRING_ID StringToken;\r
\r
if (DevicePath != NULL){\r
String = ExtractFileNameFromDevicePath(DevicePath);\r
if (DevicePath != NULL){\r
String = ExtractFileNameFromDevicePath(DevicePath);\r
- StringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, String, NULL);\r
- FreePool(String);\r
- } else {\r
+ }\r
+ if (String == NULL) {\r
String = HiiGetString (CallbackData->BmmHiiHandle, STRING_TOKEN (STR_NULL_STRING), NULL);\r
ASSERT (String != NULL);\r
String = HiiGetString (CallbackData->BmmHiiHandle, STRING_TOKEN (STR_NULL_STRING), NULL);\r
ASSERT (String != NULL);\r
- StringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, String, NULL);\r
- FreePool (String);\r
+ StringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, String, NULL);\r
+ FreePool (String);\r
+\r
if(FormId == FORM_BOOT_ADD_ID){\r
if (!CallbackData->BmmFakeNvData.BootOptionChanged) {\r
ZeroMem (CallbackData->BmmFakeNvData.BootOptionalData, sizeof (CallbackData->BmmFakeNvData.BootOptionalData));\r
if(FormId == FORM_BOOT_ADD_ID){\r
if (!CallbackData->BmmFakeNvData.BootOptionChanged) {\r
ZeroMem (CallbackData->BmmFakeNvData.BootOptionalData, sizeof (CallbackData->BmmFakeNvData.BootOptionalData));\r