MdeModulePkg HiiDataBase: Fix the potential NULL pointer reference

This change is the additional fix of commit
14b351e2ed.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
Liming Gao 2017-12-27 10:31:19 +08:00
parent 56d0bd7eb8
commit 9eefa2eca0
1 changed files with 6 additions and 4 deletions

View File

@ -845,7 +845,7 @@ UpdateDefaultSettingInFormPackage (
// //
EfiVarStoreList = ReallocatePool (EfiVarStoreMaxNum * sizeof (UINTN), (EfiVarStoreMaxNum + BASE_NUMBER) * sizeof (UINTN), EfiVarStoreList); EfiVarStoreList = ReallocatePool (EfiVarStoreMaxNum * sizeof (UINTN), (EfiVarStoreMaxNum + BASE_NUMBER) * sizeof (UINTN), EfiVarStoreList);
if (EfiVarStoreList == NULL) { if (EfiVarStoreList == NULL) {
break; goto Done;
} }
EfiVarStoreMaxNum = EfiVarStoreMaxNum + BASE_NUMBER; EfiVarStoreMaxNum = EfiVarStoreMaxNum + BASE_NUMBER;
} }
@ -874,7 +874,7 @@ UpdateDefaultSettingInFormPackage (
// //
DefaultIdList = ReallocatePool (DefaultIdMaxNum * sizeof (UINT16), (DefaultIdMaxNum + BASE_NUMBER) * sizeof (UINT16), DefaultIdList); DefaultIdList = ReallocatePool (DefaultIdMaxNum * sizeof (UINT16), (DefaultIdMaxNum + BASE_NUMBER) * sizeof (UINT16), DefaultIdList);
if (DefaultIdList == NULL) { if (DefaultIdList == NULL) {
break; goto Done;
} }
DefaultIdMaxNum = DefaultIdMaxNum + BASE_NUMBER; DefaultIdMaxNum = DefaultIdMaxNum + BASE_NUMBER;
} }
@ -1046,8 +1046,10 @@ UpdateDefaultSettingInFormPackage (
} }
Done: Done:
for (Index = 0; Index < EfiVarStoreNumber; Index ++) { if (EfiVarStoreList != NULL) {
FreePool (EfiVarStoreList [Index]); for (Index = 0; Index < EfiVarStoreNumber; Index ++) {
FreePool (EfiVarStoreList [Index]);
}
} }
return; return;
} }