diff options
author | Hao Wu <hao.a.wu@intel.com> | 2016-11-10 09:43:07 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-11-10 16:28:39 +0800 |
commit | c52f00d6e1e14b9eaf5c5a58501f075d2a64920c (patch) | |
tree | ab19702034e62adad5de5347244d5e49a5bf90b0 /BaseTools | |
parent | b390737ad03a354f5d11954950a580df715e2935 (diff) | |
download | edk2-platforms-c52f00d6e1e14b9eaf5c5a58501f075d2a64920c.tar.xz |
BaseTools/GenSec: Return correct status when input file size is 0
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>
Diffstat (limited to 'BaseTools')
-rw-r--r-- | BaseTools/Source/C/GenSec/GenSec.c | 16 |
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) {
|