]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg: Verify DevicePathToText was successful before using the resultant pointer.
authorjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 20 Sep 2011 23:06:23 +0000 (23:06 +0000)
committerjcarsey <jcarsey@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 20 Sep 2011 23:06:23 +0000 (23:06 +0000)
signed-off-by: jcarsey
reviewed-by: darylm503

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12393 6f19259b-4bc3-4df7-8a09-765794883524

ShellPkg/Library/UefiSortLib/UefiSortLib.c

index 73ee7830fc46c79597c6175721a566c7f1393aa1..9cff46d4e6e6220f8945625876ab524b62e236da 100644 (file)
@@ -13,6 +13,7 @@
 **/\r
 \r
 #include <Uefi.h>\r
+#include <ShellBase.h>\r
 \r
 #include <Protocol/UnicodeCollation.h>\r
 #include <Protocol/DevicePath.h>\r
@@ -251,13 +252,19 @@ DevicePathCompare (
     FALSE,\r
     FALSE);\r
 \r
-  RetVal = mUnicodeCollation->StriColl(\r
-    mUnicodeCollation,\r
-    TextPath1,\r
-    TextPath2);\r
+  if (TextPath1 == NULL) {\r
+    RetVal = -1;\r
+  } else if (TextPath2 == NULL) {\r
+    RetVal = 1;\r
+  } else {\r
+    RetVal = mUnicodeCollation->StriColl(\r
+      mUnicodeCollation,\r
+      TextPath1,\r
+      TextPath2);\r
+  }\r
 \r
-  FreePool(TextPath1);\r
-  FreePool(TextPath2);\r
+  SHELL_FREE_NON_NULL(TextPath1);\r
+  SHELL_FREE_NON_NULL(TextPath2);\r
 \r
   return (RetVal);\r
 }\r