From cdd95292799fc93a59ac175ded2fe7f9e8d14f1c Mon Sep 17 00:00:00 2001 From: lzeng14 Date: Thu, 3 Nov 2011 02:45:25 +0000 Subject: [PATCH] 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 --- PerformancePkg/Dp_App/Dp.c | 49 ++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/PerformancePkg/Dp_App/Dp.c b/PerformancePkg/Dp_App/Dp.c index be4d40301a..c5b8010298 100644 --- a/PerformancePkg/Dp_App/Dp.c +++ b/PerformancePkg/Dp_App/Dp.c @@ -13,7 +13,7 @@ * Dp uses this information to group records in different ways. It also uses * timer information to calculate elapsed time for each measurement. * - * Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
+ * Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
* This program and the accompanying materials * 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 @@ -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. @@ -433,23 +446,23 @@ InitializeDp ( ListIndex ++; } FreePool (DpParamList); - - FreePool (StringDpOptionQh); - FreePool (StringDpOptionLh); - FreePool (StringDpOptionUh); - FreePool (StringDpOptionLv); - FreePool (StringDpOptionUs); - FreePool (StringDpOptionLs); - FreePool (StringDpOptionUa); - FreePool (StringDpOptionUr); - FreePool (StringDpOptionUt); - FreePool (StringDpOptionUp); - FreePool (StringDpOptionLx); - FreePool (StringDpOptionLn); - FreePool (StringDpOptionLt); - FreePool (StringPtr); - FreePool (mPrintTokenBuffer); - + + SafeFreePool (StringDpOptionQh); + SafeFreePool (StringDpOptionLh); + SafeFreePool (StringDpOptionUh); + SafeFreePool (StringDpOptionLv); + SafeFreePool (StringDpOptionUs); + SafeFreePool (StringDpOptionLs); + SafeFreePool (StringDpOptionUa); + SafeFreePool (StringDpOptionUr); + SafeFreePool (StringDpOptionUt); + SafeFreePool (StringDpOptionUp); + SafeFreePool (StringDpOptionLx); + SafeFreePool (StringDpOptionLn); + SafeFreePool (StringDpOptionLt); + SafeFreePool (StringPtr); + SafeFreePool (mPrintTokenBuffer); + HiiRemovePackages (gHiiHandle); return Status; } -- 2.39.2