]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add NULL pointer check before free pool.
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 3 Nov 2011 02:45:25 +0000 (02:45 +0000)
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 3 Nov 2011 02:45:25 +0000 (02:45 +0000)
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

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