Fix bugs in CDROM_GetSerial

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




ChangeLog: * Fix a couple of bugs in CDROM_GetSerial from WineHQ. - it would fail if DeviceIoControl succeeded. - it would leak handles in some cases.
Index: files/drive.c
===================================================================
RCS file: /home/wine/wine/files/drive.c,v
retrieving revision 1.90
diff -u -r1.90 drive.c
--- files/drive.c	4 Jun 2003 20:17:52 -0000	1.90
+++ files/drive.c	21 Jul 2003 10:11:39 -0000
@@ -861,12 +861,18 @@
  */
 static DWORD CDROM_GetLabel(int drive, WCHAR *label)
 {
-    HANDLE              h = CDROM_Open(drive);
+    HANDLE              h;
     CDROM_DISK_DATA     cdd;
-    DWORD               br;
-    DWORD               ret = 1;
+    DWORD               br, ret = 1;
+    BOOL                r;
 
-    if (!h || !DeviceIoControl(h, IOCTL_CDROM_DISK_TYPE, NULL, 0, &cdd, sizeof(cdd), &br, 0))
+    h = CDROM_Open(drive);
+    if( !h ) 
+        return 0;
+    r = DeviceIoControl(h, IOCTL_CDROM_DISK_TYPE, NULL, 
+                        0, &cdd, sizeof(cdd), &br, 0);
+    CloseHandle( h );
+    if( !r )
         return 0;
 
     switch (cdd.DiskData & 0x03)
@@ -1032,12 +1038,23 @@
 static DWORD CDROM_GetSerial(int drive)
 {
     DWORD               serial = 0;
-    HANDLE              h = CDROM_Open(drive);
+    HANDLE              h;
     CDROM_DISK_DATA     cdd;
     DWORD               br;
+    BOOL                r;
+
+    TRACE("%d\n", drive);
 
-    if (!h || ! !DeviceIoControl(h, IOCTL_CDROM_DISK_TYPE, NULL, 0, &cdd, sizeof(cdd), &br, 0))
+    h = CDROM_Open(drive);
+    if( !h ) 
         return 0;
+    r = DeviceIoControl(h, IOCTL_CDROM_DISK_TYPE, NULL, 
+                        0, &cdd, sizeof(cdd), &br, 0);
+    if (!r)
+    {
+        CloseHandle(h);
+        return 0;
+    }
 
     switch (cdd.DiskData & 0x03)
     {

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux