Fix a memory management bug in apply_drive_changes to stop winecfg
authorMike Hearn <mike@navi.cx>
Sun, 9 Jan 2005 18:01:00 +0000 (18:01 +0000)
committerAlexandre Julliard <julliard@winehq.org>
Sun, 9 Jan 2005 18:01:00 +0000 (18:01 +0000)
deleting all the drive definitions in some cases.

programs/winecfg/drive.c

index f44b82888b6890d0d2019cf0d4fc6f8fef1389a3..a1a5bbc1c491015111b2e9e3c7a42e36b4392180 100644 (file)
@@ -180,6 +180,15 @@ void load_drives()
     {
         drives[i].letter = 'A' + i;
         drives[i].in_use = FALSE;
+
+        HeapFree(GetProcessHeap(), 0, drives[i].unixpath);
+        drives[i].unixpath = NULL;
+
+        HeapFree(GetProcessHeap(), 0, drives[i].label);
+        drives[i].label = NULL;
+
+        HeapFree(GetProcessHeap(), 0, drives[i].serial);
+        drives[i].serial = NULL;
     }
 
     /* work backwards through the result of GetLogicalDriveStrings  */
@@ -473,11 +482,5 @@ void apply_drive_changes()
                 WINE_TRACE("  CreateFile() error with file '%s'\n", filename);
             }
         }
-
-        /* if this drive is in use we should free it up */
-        if(drives[i].in_use)
-        {
-            delete_drive(&drives[i]); /* free up the string memory */
-        }
     }
 }