<div dir="ltr"><div>Fix memory leak in librtlsdr.</div><div><br></div><div>The problem came up when using rtlsdr_open() twice with the same index. <br></div><div>The variable dev->devh is never cleaned if libusb_claim_interface() fails. This causes a leak if the device is already claimed by another handle. <br></div><div>rtlsdr_close() did not free that space since the returned handle is invalid if libusb_claim_interface fails<br></div><div><br></div><div>Here is the patch file in text format. (it is also joined to this email).</div><div></div><div><br></div><div>~~~~</div><div>diff --git a/src/librtlsdr.c b/src/librtlsdr.c<br>index a71609b..89ec903 100644<br>--- a/src/librtlsdr.c<br>+++ b/src/librtlsdr.c<br>@@ -1520,10 +1520,6 @@ int rtlsdr_open(rtlsdr_dev_t **out_dev, uint32_t index)<br>        r = libusb_claim_interface(dev->devh, 0);<br>        if (r < 0) {<br>                fprintf(stderr, "usb_claim_interface error %d\n", r);<br>-               if (dev) <br>-               {<br>-               libusb_close(dev->devh);<br>-               }<br>                goto err;<br>        }<br></div><div>~~~~<br></div><div> </div><div>-Vincent Perrier<br></div><div><br></div></div>