Hardware scanning creates an ftdi_context before attempting to locate devices
based on PID/VID. If no devices are detected, execution jumps to cleanup. The
context is freed with free(), instead of ftdi_free().
We cannot assume that the libftdi context is stored in a contiguous memory
region, and thus cannot use a simple free. Case in point, this situation is
identified by valgrind as a "definitely lost" memory leak.
Use ftdi_free() instead of a simple free() in hw_scan(). Valgrind no longer
complains about a memory leak in this area.
clear_instances() does not need any modification, as it correctly uses
ftdi_free().
Signed-off-by: Alexandru Gagniuc <redacted>
err_close_ftdic:
(void) la8_close(devc); /* Log, but ignore errors. */
err_free_ftdic:
- free(devc->ftdic); /* NOT g_free()! */
+ ftdi_free(devc->ftdic); /* NOT free() or g_free()! */
err_free_final_buf:
g_free(devc->final_buf);
err_free_devc: