diff options
author | Hao Wu <hao.a.wu@intel.com> | 2016-10-11 15:27:55 +0800 |
---|---|---|
committer | Hao Wu <hao.a.wu@intel.com> | 2016-11-08 16:37:52 +0800 |
commit | 85006654944a0f9e64974f23705beb7bc4906bcc (patch) | |
tree | 0b9d6c7eeb15c0156924a022af83d6a127411ed9 /BaseTools/Source/C | |
parent | bdf5f73120b6db1b598a6ac7f17a9d5f6cca7c35 (diff) | |
download | edk2-platforms-85006654944a0f9e64974f23705beb7bc4906bcc.tar.xz |
BaseTools/VolInfo: Fix potential memory leak
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/Source/C')
-rw-r--r-- | BaseTools/Source/C/VolInfo/VolInfo.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/BaseTools/Source/C/VolInfo/VolInfo.c b/BaseTools/Source/C/VolInfo/VolInfo.c index 5da658298e..312d33221b 100644 --- a/BaseTools/Source/C/VolInfo/VolInfo.c +++ b/BaseTools/Source/C/VolInfo/VolInfo.c @@ -258,6 +258,14 @@ Returns: continue;
}
if ((stricmp (argv[0], "--hash") == 0)) {
+ if (EnableHash == TRUE) {
+ //
+ // --hash already given in the option, ignore this one
+ //
+ argc --;
+ argv ++;
+ continue;
+ }
EnableHash = TRUE;
OpenSslCommand = "openssl";
OpenSslEnv = getenv("OPENSSL_PATH");
@@ -1784,8 +1792,14 @@ Returns: }
ScratchBuffer = malloc (ScratchSize);
+ if (ScratchBuffer == NULL) {
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+ return EFI_OUT_OF_RESOURCES;
+ }
UncompressedBuffer = malloc (UncompressedLength);
- if ((ScratchBuffer == NULL) || (UncompressedBuffer == NULL)) {
+ if (UncompressedBuffer == NULL) {
+ free (ScratchBuffer);
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
return EFI_OUT_OF_RESOURCES;
}
Status = DecompressFunction (
|