BaseTools/DevicePath: Fix potential null pointer dereference

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Hao Wu 2018-01-03 19:31:37 +08:00
parent 66329d53bd
commit e73fbac5d7
1 changed files with 5 additions and 0 deletions

View File

@ -183,6 +183,11 @@ int main(int argc, CHAR8 *argv[])
}
Ascii2UnicodeString(Str, Str16);
DevicePath = UefiDevicePathLibConvertTextToDevicePath(Str16);
if (DevicePath == NULL) {
fprintf(stderr, "Convert fail, Cannot convert text to a device path");
free(Str16);
return STATUS_ERROR;
}
while (!((DevicePath->Type == END_DEVICE_PATH_TYPE) && (DevicePath->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)) )
{
PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] << 8);