[CABMAN]
authorThomas Faber <thomas.faber@reactos.org>
Fri, 17 Jan 2014 16:07:32 +0000 (16:07 +0000)
committerThomas Faber <thomas.faber@reactos.org>
Fri, 17 Jan 2014 16:07:32 +0000 (16:07 +0000)
- Fix a memory leak

svn path=/trunk/; revision=61652

reactos/tools/cabman/cabinet.cxx

index b56a401..0f23b07 100644 (file)
@@ -634,22 +634,26 @@ bool CCabinet::SetCabinetReservedFile(char* FileName)
 {
     FILEHANDLE FileHandle;
     ULONG BytesRead;
+    char* ConvertedFileName;
 
+    ConvertedFileName = ConvertPath(FileName, true);
 #if defined(_WIN32)
-    FileHandle = CreateFile(ConvertPath(FileName, true),  // Open this file
+    FileHandle = CreateFile(ConvertedFileName,  // Open this file
         GENERIC_READ,                    // Open for reading
         FILE_SHARE_READ,                 // Share for reading
         NULL,                            // No security
         OPEN_EXISTING,                   // Existing file only
         FILE_ATTRIBUTE_NORMAL,           // Normal file
         NULL);                           // No attribute template
+    free(ConvertedFileName);
     if (FileHandle == INVALID_HANDLE_VALUE)
     {
         DPRINT(MID_TRACE, ("Cannot open cabinet reserved file.\n"));
         return false;
     }
 #else /* !_WIN32 */
-    FileHandle = fopen(ConvertPath(FileName, true), "rb");
+    FileHandle = fopen(ConvertedFileName, "rb");
+    free(ConvertedFileName);
     if (FileHandle == NULL)
     {
         DPRINT(MID_TRACE, ("Cannot open cabinet reserved file.\n"));