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>
This commit is contained in:
Hao Wu 2016-11-10 09:43:07 +08:00
parent b390737ad0
commit c52f00d6e1
1 changed files with 11 additions and 5 deletions

View File

@ -897,16 +897,22 @@ 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
//