From: Lars-Peter Clausen Date: Fri, 29 Apr 2016 08:25:18 +0000 (+0200) Subject: baylibre-acme: Properly free GErrors returned by g_file_get_contents() X-Git-Tag: libsigrok-0.5.0~471 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a64fec2b8ed14d6b14daca9a3552d4c5d89a9baa;p=libsigrok.git baylibre-acme: Properly free GErrors returned by g_file_get_contents() When g_file_get_contents() encounters an error a new GError will be allocated and passed back to the application. The application is responsible for freeing this GError. The baylibre-acme driver currently does not do this and as a result leaks memory during the scan process when no device is found. Add the missing g_error_free() invocations to fix the issue. Signed-off-by: Lars-Peter Clausen --- diff --git a/src/hardware/baylibre-acme/protocol.c b/src/hardware/baylibre-acme/protocol.c index c09e91aa..f6ceaf5d 100644 --- a/src/hardware/baylibre-acme/protocol.c +++ b/src/hardware/baylibre-acme/protocol.c @@ -167,6 +167,7 @@ SR_PRIV gboolean bl_acme_detect_probe(unsigned int addr, sr_dbg("Name for probe %d can't be read: %s", prb_num, err->message); g_string_free(path, TRUE); + g_error_free(err); return ret; } @@ -201,6 +202,7 @@ static int get_hwmon_index(unsigned int addr) if (!dir) { sr_err("Error opening %s: %s", path->str, err->message); g_string_free(path, TRUE); + g_error_free(err); return -1; } @@ -484,6 +486,7 @@ SR_PRIV int bl_acme_get_shunt(const struct sr_channel_group *cg, if (!status) { sr_err("Error reading shunt resistance: %s", err->message); ret = SR_ERR_IO; + g_error_free(err); goto out; }