From eca218a7cee77c255ee5992590e8e4bb1c20a662 Mon Sep 17 00:00:00 2001 From: jcarsey Date: Tue, 20 Sep 2011 23:06:23 +0000 Subject: ShellPkg: Verify DevicePathToText was successful before using the resultant pointer. 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 | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'ShellPkg') diff --git a/ShellPkg/Library/UefiSortLib/UefiSortLib.c b/ShellPkg/Library/UefiSortLib/UefiSortLib.c index 73ee7830fc..9cff46d4e6 100644 --- a/ShellPkg/Library/UefiSortLib/UefiSortLib.c +++ b/ShellPkg/Library/UefiSortLib/UefiSortLib.c @@ -13,6 +13,7 @@ **/ #include +#include #include #include @@ -251,13 +252,19 @@ DevicePathCompare ( FALSE, FALSE); - RetVal = mUnicodeCollation->StriColl( - mUnicodeCollation, - TextPath1, - TextPath2); + if (TextPath1 == NULL) { + RetVal = -1; + } else if (TextPath2 == NULL) { + RetVal = 1; + } else { + RetVal = mUnicodeCollation->StriColl( + mUnicodeCollation, + TextPath1, + TextPath2); + } - FreePool(TextPath1); - FreePool(TextPath2); + SHELL_FREE_NON_NULL(TextPath1); + SHELL_FREE_NON_NULL(TextPath2); return (RetVal); } -- cgit v1.2.3