summaryrefslogtreecommitdiff
path: root/BaseTools
diff options
context:
space:
mode:
Diffstat (limited to 'BaseTools')
-rw-r--r--BaseTools/Source/C/GenSec/GenSec.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/BaseTools/Source/C/GenSec/GenSec.c b/BaseTools/Source/C/GenSec/GenSec.c
index 87d4fa88b9..9129b5067e 100644
--- a/BaseTools/Source/C/GenSec/GenSec.c
+++ b/BaseTools/Source/C/GenSec/GenSec.c
@@ -897,17 +897,23 @@ Returns:
return Status;
}
- if (FileBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
if (InputLength == 0) {
- free (FileBuffer);
+ if (FileBuffer != NULL) {
+ free (FileBuffer);
+ }
Error (NULL, 0, 2000, "Invalid parameter", "the size of input file %s can't be zero", InputFileName);
return EFI_NOT_FOUND;
}
//
+ // InputLength != 0, but FileBuffer == NULL means out of resources.
+ //
+ if (FileBuffer == NULL) {
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated");
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
// Now data is in FileBuffer + Offset
//
if (CompareGuid (VendorGuid, &mZeroGuid) == 0) {