]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.c
MdePkg/UefiFileHandleLib: Fix potential NULL dereference
[mirror_edk2.git] / MdePkg / Library / UefiFileHandleLib / UefiFileHandleLib.c
index 96913c5c02b8deddbc80bdc0fa08f58febb110e5..5dc893833a4667492ee33d0ae4643025f514ac24 100644 (file)
@@ -68,19 +68,21 @@ FileHandleGetInfo (
     // error is expected.  getting size to allocate\r
     //\r
     FileInfo = AllocateZeroPool(FileInfoSize);\r
-    //\r
-    // now get the information\r
-    //\r
-    Status = FileHandle->GetInfo(FileHandle,\r
-                                 &gEfiFileInfoGuid,\r
-                                 &FileInfoSize,\r
-                                 FileInfo);\r
-    //\r
-    // if we got an error free the memory and return NULL\r
-    //\r
-    if (EFI_ERROR(Status) && (FileInfo != NULL)) {\r
-      FreePool(FileInfo);\r
-      FileInfo = NULL;\r
+    if (FileInfo != NULL) {\r
+      //\r
+      // now get the information\r
+      //\r
+      Status = FileHandle->GetInfo(FileHandle,\r
+                                   &gEfiFileInfoGuid,\r
+                                   &FileInfoSize,\r
+                                   FileInfo);\r
+      //\r
+      // if we got an error free the memory and return NULL\r
+      //\r
+      if (EFI_ERROR(Status)) {\r
+        FreePool(FileInfo);\r
+        FileInfo = NULL;\r
+      }\r
     }\r
   }\r
   return (FileInfo);\r