]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiShellDebug1CommandsLib/Comp.c
ShellPkg: Add checking for memory allocation and pointer returns from functions.
[mirror_edk2.git] / ShellPkg / Library / UefiShellDebug1CommandsLib / Comp.c
index b59ef31682c5917bd072eda03c4bda874c7231af..01ef1997b2dfe577c483f3599f0e8ef9d35239dc 100644 (file)
@@ -49,6 +49,7 @@ ShellCommandRunComp (
   UINTN               DataSizeFromFile2;\r
   CHAR16              *FileName1;\r
   CHAR16              *FileName2;\r
+  CONST CHAR16        *TempParam;\r
 \r
   ErrorCount          = 0;\r
   ShellStatus         = SHELL_SUCCESS;\r
@@ -88,25 +89,29 @@ ShellCommandRunComp (
       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_FEW), gShellDebug1HiiHandle);\r
       ShellStatus = SHELL_INVALID_PARAMETER;\r
     } else {\r
-      FileName1 = ShellFindFilePath(ShellCommandLineGetRawValue(Package, 1));\r
+      TempParam = ShellCommandLineGetRawValue(Package, 1);\r
+      ASSERT(TempParam != NULL);\r
+      FileName1 = ShellFindFilePath(TempParam);\r
       if (FileName1 == NULL) {\r
-        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1));\r
+        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, TempParam);\r
         ShellStatus = SHELL_NOT_FOUND;\r
       } else {\r
         Status = ShellOpenFileByName(FileName1, &FileHandle1, EFI_FILE_MODE_READ, 0);\r
         if (EFI_ERROR(Status)) {\r
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 1), Status);\r
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, TempParam, Status);\r
           ShellStatus = SHELL_NOT_FOUND;\r
         }\r
       }\r
-      FileName2 = ShellFindFilePath(ShellCommandLineGetRawValue(Package, 2));\r
+      TempParam = ShellCommandLineGetRawValue(Package, 2);\r
+      ASSERT(TempParam != NULL);\r
+      FileName2 = ShellFindFilePath(TempParam);\r
       if (FileName2 == NULL) {\r
-        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2));\r
+        ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_FIND_FAIL), gShellDebug1HiiHandle, TempParam);\r
         ShellStatus = SHELL_NOT_FOUND;\r
       } else {\r
         Status = ShellOpenFileByName(FileName2, &FileHandle2, EFI_FILE_MODE_READ, 0);\r
         if (EFI_ERROR(Status)) {\r
-          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, ShellCommandLineGetRawValue(Package, 2), Status);\r
+          ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_FILE_OPEN_FAIL), gShellDebug1HiiHandle, TempParam, Status);\r
           ShellStatus = SHELL_NOT_FOUND;\r
         }\r
       }\r