]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/GenSec: Return correct status when input file size is 0
authorHao Wu <hao.a.wu@intel.com>
Thu, 10 Nov 2016 01:43:07 +0000 (09:43 +0800)
committerHao Wu <hao.a.wu@intel.com>
Thu, 10 Nov 2016 08:28:39 +0000 (16:28 +0800)
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/C/GenSec/GenSec.c

index 87d4fa88b92dd61937a91bfb85cebf1a4e5276c8..9129b5067e7f28ef4d0bd929854ef7a7472ad4f3 100644 (file)
@@ -897,16 +897,22 @@ Returns:
     return Status;\r
   }\r
 \r
-  if (FileBuffer == NULL) {\r
-    return EFI_OUT_OF_RESOURCES;\r
-  }\r
-\r
   if (InputLength == 0) {\r
-    free (FileBuffer);\r
+    if (FileBuffer != NULL) {\r
+      free (FileBuffer);\r
+    }\r
     Error (NULL, 0, 2000, "Invalid parameter", "the size of input file %s can't be zero", InputFileName);\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
+  //\r
+  // InputLength != 0, but FileBuffer == NULL means out of resources.\r
+  //\r
+  if (FileBuffer == NULL) {\r
+    Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated");\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
   //\r
   // Now data is in FileBuffer + Offset\r
   //\r