tags 561113 +patch
--

I don`t see any problems to support it in this file if it will not break real FreeBSD. I already changed this file to support OS_VERSION in it, so i see no problems to accept correct patches from FreeBSD deviants.

Hi,

please could you apply the attached patch.
In fact there have been two double free() ;-)

The 1st one is due to realloc(p,0) returns NULL,
the free(p) have been called twice in this case.
This affects only GNU/kFreeBSD.

The 2nd one is due to cam_close_device(cam_dev) called twice
under some condition. This affects both pristine FreeBSD and GNU/kFreeBSD.

The patch have been tested by me and Axel, see [1].

Thanks
        Petr

[1] http://bugs.debian.org//cgi-bin/bugreport.cgi?bug=561113
--- os_freebsd.cpp
+++ os_freebsd.cpp
@@ -165,7 +165,7 @@
 #ifdef __GLIBC__
 static inline void * reallocf(void *ptr, size_t size) {
    void *rv = realloc(ptr, size);
-   if(rv == NULL)
+   if((rv == NULL) && (size != 0))
      free(ptr);
    return rv;
    }
@@ -1800,10 +1800,10 @@
           cam_close_device(cam_dev);
           if(usbdevlist(bus,vendor_id, product_id, version)){
             const char * usbtype = get_usb_dev_type_by_id(vendor_id, product_id, version);
-            if (!usbtype)
-              return false;
-            return get_sat_device(usbtype, new freebsd_scsi_device(this, name, ""));
+            if (usbtype)
+              return get_sat_device(usbtype, new freebsd_scsi_device(this, name, ""));
           }
+          return false;
         }
 #if FREEBSDVER > 800100
         // check if we have ATA device connected to CAM (ada)

Reply via email to