MdeModulePkg/HiiDatabaseDxe: Fix memory leak issues in HiiDatabaseDxe

Cc: Qiu Shumin <shumin.qiu@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Qiu Shumin <shumin.qiu@intel.com>
This commit is contained in:
Dandan Bi 2016-04-27 18:00:02 +08:00 committed by Star Zeng
parent fdd530d61b
commit a0b0cd7391
1 changed files with 20 additions and 1 deletions

View File

@ -549,6 +549,8 @@ FindSameBlockElement(
ASSERT (TempBuffer != NULL); ASSERT (TempBuffer != NULL);
if ((BufferLen == Length) && (0 == CompareMem (Buffer, TempBuffer, Length))) { if ((BufferLen == Length) && (0 == CompareMem (Buffer, TempBuffer, Length))) {
*Found = TRUE; *Found = TRUE;
FreePool (TempBuffer);
TempBuffer = NULL;
return EFI_SUCCESS; return EFI_SUCCESS;
} else { } else {
FreePool (TempBuffer); FreePool (TempBuffer);
@ -1887,6 +1889,9 @@ IsThisPackageList (
if (IsThisVarstore((VOID *)&IfrVarStore->Guid, VarStoreName, ConfigHdr)) { if (IsThisVarstore((VOID *)&IfrVarStore->Guid, VarStoreName, ConfigHdr)) {
FindVarstore = TRUE; FindVarstore = TRUE;
goto Done; goto Done;
} else {
FreePool (VarStoreName);
VarStoreName = NULL;
} }
break; break;
@ -1901,6 +1906,9 @@ IsThisPackageList (
if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr)) { if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr)) {
FindVarstore = TRUE; FindVarstore = TRUE;
goto Done; goto Done;
} else {
FreePool (VarStoreName);
VarStoreName = NULL;
} }
break; break;
@ -2094,6 +2102,7 @@ ParseIfrData (
FirstOneOfOption = FALSE; FirstOneOfOption = FALSE;
VarStoreId = 0; VarStoreId = 0;
FirstOrderedList = FALSE; FirstOrderedList = FALSE;
VarStoreName = NULL;
ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA)); ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA));
// //
@ -2151,6 +2160,9 @@ ParseIfrData (
VarStorageData->Name = VarStoreName; VarStorageData->Name = VarStoreName;
VarStorageData->Type = EFI_HII_VARSTORE_BUFFER; VarStorageData->Type = EFI_HII_VARSTORE_BUFFER;
VarStoreId = IfrVarStore->VarStoreId; VarStoreId = IfrVarStore->VarStoreId;
} else {
FreePool (VarStoreName);
VarStoreName = NULL;
} }
break; break;
@ -2189,6 +2201,9 @@ ParseIfrData (
VarStorageData->Name = VarStoreName; VarStorageData->Name = VarStoreName;
VarStorageData->Type = EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER; VarStorageData->Type = EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER;
VarStoreId = IfrEfiVarStore->VarStoreId; VarStoreId = IfrEfiVarStore->VarStoreId;
} else {
FreePool (VarStoreName);
VarStoreName = NULL;
} }
break; break;
@ -3014,7 +3029,7 @@ GetBlockElement (
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Done; goto Done;
} }
FreePool (TmpBuffer);
StringPtr += Length; StringPtr += Length;
if (*StringPtr != 0 && *StringPtr != L'&') { if (*StringPtr != 0 && *StringPtr != L'&') {
goto Done; goto Done;
@ -3868,6 +3883,10 @@ Done:
} }
FreePool (BlockData); FreePool (BlockData);
} }
if (VarStorageData ->Name != NULL) {
FreePool (VarStorageData ->Name);
VarStorageData ->Name = NULL;
}
FreePool (VarStorageData); FreePool (VarStorageData);
} }