]> sigrok.org Git - libsigrok.git/commit - hardware/chronovu-la8/api.c
chronovu-la8: Fix memory leak in hw_scan
authorAlexandru Gagniuc <redacted>
Mon, 17 Dec 2012 08:04:35 +0000 (02:04 -0600)
committerUwe Hermann <redacted>
Tue, 18 Dec 2012 01:08:36 +0000 (02:08 +0100)
commit4f9bf9a202d331b0f2ec088d73d72808e1a934b4
tree3ec2ab3c05d136fc46817ad6d088ad6c37b0b993
parentc0bf69c29b138d18ee9f542985664eeaeeb47a0a
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 <redacted>
hardware/chronovu-la8/api.c