chronovu-la8: Fix memory leak in hw_scan

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 <mr.nuke.me@gmail.com>
This commit is contained in:
Alexandru Gagniuc 2012-12-17 02:04:35 -06:00 committad av Uwe Hermann
förälder c0bf69c29b
incheckning 4f9bf9a202
1 ändrade filer med 1 tillägg och 1 borttagningar

Visa fil

@ -179,7 +179,7 @@ static GSList *hw_scan(GSList *options)
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: