Add NULL pointer check before free pool.

Signed-off-by: lzeng14
Reviewed-by: rsun3

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12656 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lzeng14 2011-11-03 02:45:25 +00:00
parent d09ed37fb1
commit cdd9529279

View File

@ -13,7 +13,7 @@
* Dp uses this information to group records in different ways. It also uses * Dp uses this information to group records in different ways. It also uses
* timer information to calculate elapsed time for each measurement. * timer information to calculate elapsed time for each measurement.
* *
* Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR> * Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
* This program and the accompanying materials * This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License * are licensed and made available under the terms and conditions of the BSD License
* which accompanies this distribution. The full text of the license may be found at * which accompanies this distribution. The full text of the license may be found at
@ -85,6 +85,19 @@ PARAM_ITEM_LIST ParamList[] = {
///@} ///@}
/**
Wrap original FreePool to check NULL pointer first.
**/
VOID
SafeFreePool (
IN VOID *Buffer
)
{
if (Buffer != NULL) {
FreePool (Buffer);
}
}
/** /**
Transfer the param list value and get the command line parse. Transfer the param list value and get the command line parse.
@ -433,23 +446,23 @@ InitializeDp (
ListIndex ++; ListIndex ++;
} }
FreePool (DpParamList); FreePool (DpParamList);
FreePool (StringDpOptionQh); SafeFreePool (StringDpOptionQh);
FreePool (StringDpOptionLh); SafeFreePool (StringDpOptionLh);
FreePool (StringDpOptionUh); SafeFreePool (StringDpOptionUh);
FreePool (StringDpOptionLv); SafeFreePool (StringDpOptionLv);
FreePool (StringDpOptionUs); SafeFreePool (StringDpOptionUs);
FreePool (StringDpOptionLs); SafeFreePool (StringDpOptionLs);
FreePool (StringDpOptionUa); SafeFreePool (StringDpOptionUa);
FreePool (StringDpOptionUr); SafeFreePool (StringDpOptionUr);
FreePool (StringDpOptionUt); SafeFreePool (StringDpOptionUt);
FreePool (StringDpOptionUp); SafeFreePool (StringDpOptionUp);
FreePool (StringDpOptionLx); SafeFreePool (StringDpOptionLx);
FreePool (StringDpOptionLn); SafeFreePool (StringDpOptionLn);
FreePool (StringDpOptionLt); SafeFreePool (StringDpOptionLt);
FreePool (StringPtr); SafeFreePool (StringPtr);
FreePool (mPrintTokenBuffer); SafeFreePool (mPrintTokenBuffer);
HiiRemovePackages (gHiiHandle); HiiRemovePackages (gHiiHandle);
return Status; return Status;
} }