Dear list,
if libusb open fails (e.g. permission problem) then ftdi_init leaks the memory for the eeprom data. Patch included.
Kind regards,
Rolf
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [email protected]
diff --git a/src/ftdi.c b/src/ftdi.c
index f5d263c..072f3ba 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -87,7 +87,7 @@ static void ftdi_usb_close_internal (struct ftdi_context *ftdi)
*/
int ftdi_init(struct ftdi_context *ftdi)
{
- struct ftdi_eeprom* eeprom = (struct ftdi_eeprom *)malloc(sizeof(struct ftdi_eeprom));
+ struct ftdi_eeprom* eeprom;
ftdi->usb_ctx = NULL;
ftdi->usb_dev = NULL;
ftdi->usb_read_timeout = 5000;
@@ -111,6 +111,7 @@ int ftdi_init(struct ftdi_context *ftdi)
ftdi_set_interface(ftdi, INTERFACE_ANY);
ftdi->bitbang_mode = 1; /* when bitbang is enabled this holds the number of the mode */
+ eeprom = (struct ftdi_eeprom *)malloc(sizeof(struct ftdi_eeprom));
if (eeprom == 0)
ftdi_error_return(-2, "Can't malloc struct ftdi_eeprom");
memset(eeprom, 0, sizeof(struct ftdi_eeprom));
