]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/C/VolInfo/VolInfo.c
BaseTools/VolInfo: Fix potential memory leak
[mirror_edk2.git] / BaseTools / Source / C / VolInfo / VolInfo.c
index 5da658298e17aca8af7150ec0555d618e31707cd..312d33221b8c3f56174bab22a9f47f58150f166b 100644 (file)
@@ -258,6 +258,14 @@ Returns:
       continue;\r
     }\r
     if ((stricmp (argv[0], "--hash") == 0)) {\r
+      if (EnableHash == TRUE) {\r
+        //\r
+        // --hash already given in the option, ignore this one\r
+        //\r
+        argc --;\r
+        argv ++;\r
+        continue;\r
+      }\r
       EnableHash = TRUE;\r
       OpenSslCommand = "openssl";\r
       OpenSslEnv = getenv("OPENSSL_PATH");\r
@@ -1784,8 +1792,14 @@ Returns:
         }\r
 \r
         ScratchBuffer       = malloc (ScratchSize);\r
+        if (ScratchBuffer == NULL) {\r
+          Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");\r
+          return EFI_OUT_OF_RESOURCES;\r
+        }\r
         UncompressedBuffer  = malloc (UncompressedLength);\r
-        if ((ScratchBuffer == NULL) || (UncompressedBuffer == NULL)) {\r
+        if (UncompressedBuffer == NULL) {\r
+          free (ScratchBuffer);\r
+          Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");\r
           return EFI_OUT_OF_RESOURCES;\r
         }\r
         Status = DecompressFunction (\r