MdeModulePkg/BootMaintUi: Add error handling codes when AllocatePool fail
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>
This commit is contained in:
@@ -379,6 +379,7 @@ ExtractFileNameFromDevicePath (
|
||||
String = UiDevicePathToStr(DevicePath);
|
||||
MatchString = String;
|
||||
LastMatch = String;
|
||||
FileName = NULL;
|
||||
|
||||
while(MatchString != NULL){
|
||||
LastMatch = MatchString + 1;
|
||||
@@ -387,7 +388,9 @@ ExtractFileNameFromDevicePath (
|
||||
|
||||
Length = StrLen(LastMatch);
|
||||
FileName = AllocateCopyPool ((Length + 1) * sizeof(CHAR16), LastMatch);
|
||||
*(FileName + Length) = 0;
|
||||
if (FileName != NULL) {
|
||||
*(FileName + Length) = 0;
|
||||
}
|
||||
|
||||
FreePool(String);
|
||||
|
||||
|
Reference in New Issue
Block a user