From a0b0cd7391fe31a76ef62c639ebe0f6072145557 Mon Sep 17 00:00:00 2001 From: Dandan Bi Date: Wed, 27 Apr 2016 18:00:02 +0800 Subject: [PATCH] MdeModulePkg/HiiDatabaseDxe: Fix memory leak issues in HiiDatabaseDxe Cc: Qiu Shumin Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi Reviewed-by: Eric Dong Reviewed-by: Qiu Shumin --- .../Universal/HiiDatabaseDxe/ConfigRouting.c | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index cc155ccc61..a704734b30 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c @@ -549,6 +549,8 @@ FindSameBlockElement( ASSERT (TempBuffer != NULL); if ((BufferLen == Length) && (0 == CompareMem (Buffer, TempBuffer, Length))) { *Found = TRUE; + FreePool (TempBuffer); + TempBuffer = NULL; return EFI_SUCCESS; } else { FreePool (TempBuffer); @@ -1887,6 +1889,9 @@ IsThisPackageList ( if (IsThisVarstore((VOID *)&IfrVarStore->Guid, VarStoreName, ConfigHdr)) { FindVarstore = TRUE; goto Done; + } else { + FreePool (VarStoreName); + VarStoreName = NULL; } break; @@ -1901,6 +1906,9 @@ IsThisPackageList ( if (IsThisVarstore (&IfrEfiVarStore->Guid, VarStoreName, ConfigHdr)) { FindVarstore = TRUE; goto Done; + } else { + FreePool (VarStoreName); + VarStoreName = NULL; } break; @@ -2094,6 +2102,7 @@ ParseIfrData ( FirstOneOfOption = FALSE; VarStoreId = 0; FirstOrderedList = FALSE; + VarStoreName = NULL; ZeroMem (&DefaultData, sizeof (IFR_DEFAULT_DATA)); // @@ -2151,6 +2160,9 @@ ParseIfrData ( VarStorageData->Name = VarStoreName; VarStorageData->Type = EFI_HII_VARSTORE_BUFFER; VarStoreId = IfrVarStore->VarStoreId; + } else { + FreePool (VarStoreName); + VarStoreName = NULL; } break; @@ -2189,6 +2201,9 @@ ParseIfrData ( VarStorageData->Name = VarStoreName; VarStorageData->Type = EFI_HII_VARSTORE_EFI_VARIABLE_BUFFER; VarStoreId = IfrEfiVarStore->VarStoreId; + } else { + FreePool (VarStoreName); + VarStoreName = NULL; } break; @@ -3014,7 +3029,7 @@ GetBlockElement ( if (EFI_ERROR (Status)) { goto Done; } - + FreePool (TmpBuffer); StringPtr += Length; if (*StringPtr != 0 && *StringPtr != L'&') { goto Done; @@ -3868,6 +3883,10 @@ Done: } FreePool (BlockData); } + if (VarStorageData ->Name != NULL) { + FreePool (VarStorageData ->Name); + VarStorageData ->Name = NULL; + } FreePool (VarStorageData); }