]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/Perf.c
Add more check to make sure code run safely.
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Dxe / EfiDriverLib / Perf.c
index 497c0cf4959986867d9788e848126a516703dd8c..96f11bb44d76e32280610a7ac5ca11298fc48f5c 100644 (file)
@@ -1,6 +1,6 @@
 /*++\r
 \r
-Copyright (c) 2004 - 2005, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2010, 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
@@ -825,6 +825,11 @@ Returns:
     return EFI_OUT_OF_RESOURCES;\r
   }\r
 \r
+  //\r
+  // Initialize 'LogHob' to NULL before usage.\r
+  //\r
+  LogHob = NULL;\r
+\r
   if (Ticker != 0) {\r
     TimerValue = Ticker;\r
   } else {\r
@@ -837,7 +842,10 @@ Returns:
   EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);\r
   do {\r
     Status = GetNextGuidHob (&HobList, &gEfiPeiPerformanceHobGuid, (VOID **) &LogHob, NULL);\r
-    if (EFI_ERROR (Status)) {\r
+    if (EFI_ERROR (Status) || (LogHob == NULL)) {\r
+      //\r
+      // Failed to get HOB for ProtocolGuid.\r
+      //\r
       break;\r
     }\r
 \r