]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Nt32Pkg/WinNtSimpleFileSystemDxe: Fix memory leak
authorRuiyu Ni <ruiyu.ni@intel.com>
Thu, 24 Dec 2015 06:30:55 +0000 (06:30 +0000)
committerniruiyu <niruiyu@Edk2>
Thu, 24 Dec 2015 06:30:55 +0000 (06:30 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19513 6f19259b-4bc3-4df7-8a09-765794883524

Nt32Pkg/WinNtSimpleFileSystemDxe/WinNtSimpleFileSystem.c

index 1c300b6930f2568262d2eb628978b36bb4fcb562..feef184edb2b02d3d5a45811147093e75c9b160e 100644 (file)
@@ -1,6 +1,6 @@
 /**@file\r
 \r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, 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
@@ -628,6 +628,7 @@ Returns:
   StrCat (TempFileName, L"\\*");\r
 \r
   PrivateFile->LHandle = PrivateFile->WinNtThunk->FindFirstFile (TempFileName, &PrivateFile->FindBuf);\r
+  FreePool (TempFileName);\r
 \r
   if (PrivateFile->LHandle == INVALID_HANDLE_VALUE) {\r
     PrivateFile->IsValidFindBuf = FALSE;\r
@@ -1188,6 +1189,7 @@ Returns:
         Status = EFI_NOT_FOUND;\r
       }\r
 \r
+      FreePool (TempFileName);\r
       goto Done;\r
     }\r
 \r
@@ -1196,6 +1198,7 @@ Returns:
     //\r
     StrCat (TempFileName, L"\\*");\r
     NewPrivateFile->LHandle = NewPrivateFile->WinNtThunk->FindFirstFile (TempFileName, &NewPrivateFile->FindBuf);\r
+    FreePool (TempFileName);\r
 \r
     if (NewPrivateFile->LHandle == INVALID_HANDLE_VALUE) {\r
       NewPrivateFile->IsValidFindBuf = FALSE;\r
@@ -1276,12 +1279,14 @@ Returns:
     Status = WinNtSimpleFileSystemGetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, &InfoSize, Info);\r
 \r
     if (EFI_ERROR (Status)) {\r
+      FreePool (Info);\r
       goto Done;\r
     }\r
 \r
     Info->Attribute = Attributes;\r
 \r
     WinNtSimpleFileSystemSetInfo (&NewPrivateFile->EfiFile, &gEfiFileInfoGuid, InfoSize, Info);\r
+    FreePool (Info);\r
   }\r
 \r
 Done:\r
@@ -1361,6 +1366,10 @@ Returns:
     FreePool (PrivateFile->FileName);\r
   }\r
 \r
+  if (PrivateFile->FilePath) {\r
+    FreePool (PrivateFile->FilePath);\r
+  }\r
+\r
   FreePool (PrivateFile);\r
 \r
   gBS->RestoreTPL (OldTpl);\r
@@ -1431,6 +1440,7 @@ Returns:
   }\r
 \r
   FreePool (PrivateFile->FileName);\r
+  FreePool (PrivateFile->FilePath);\r
   FreePool (PrivateFile);\r
 \r
   gBS->RestoreTPL (OldTpl);\r