]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/DevicePath/DevicePath.c
BaseTools: expression can use single in instead of 3 API calls.
[mirror_edk2.git] / BaseTools / Source / C / DevicePath / DevicePath.c
index 76b8553b7145296b886176151eedf66fc8a93fb9..956bbffb5f245de17957a437493e000881678b2d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Definition for Device Path Tool.\r
 \r
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2017 - 2018, 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
@@ -183,6 +183,11 @@ int main(int argc, CHAR8 *argv[])
   }\r
   Ascii2UnicodeString(Str, Str16);\r
   DevicePath = UefiDevicePathLibConvertTextToDevicePath(Str16);\r
+  if (DevicePath == NULL) {\r
+    fprintf(stderr, "Convert fail, Cannot convert text to a device path");\r
+    free(Str16);\r
+    return STATUS_ERROR;\r
+  }\r
   while (!((DevicePath->Type == END_DEVICE_PATH_TYPE) && (DevicePath->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)) )\r
   {\r
     PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] << 8);\r
@@ -190,5 +195,6 @@ int main(int argc, CHAR8 *argv[])
   }\r
   PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] << 8);\r
   putchar('\n');\r
+  free(Str16);\r
   return STATUS_SUCCESS;\r
 }\r