summaryrefslogtreecommitdiff
path: root/PerformancePkg/Dp_App/Dp.c
diff options
context:
space:
mode:
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-03 02:45:25 +0000
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>2011-11-03 02:45:25 +0000
commitcdd95292799fc93a59ac175ded2fe7f9e8d14f1c (patch)
treef912ade08108d182b8d2fe635eca28d90aa5c7bd /PerformancePkg/Dp_App/Dp.c
parentd09ed37fb138cb4ea13235e3046e8cddbfda5c12 (diff)
downloadedk2-platforms-cdd95292799fc93a59ac175ded2fe7f9e8d14f1c.tar.xz
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
Diffstat (limited to 'PerformancePkg/Dp_App/Dp.c')
-rw-r--r--PerformancePkg/Dp_App/Dp.c49
1 files 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.<BR>
+ * Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
* 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
@@ -86,6 +86,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;
}