]> sigrok.org Git - libsigrok.git/commitdiff
baylibre-acme: Properly free GErrors returned by g_file_get_contents()
authorLars-Peter Clausen <redacted>
Fri, 29 Apr 2016 08:25:18 +0000 (10:25 +0200)
committerLars-Peter Clausen <redacted>
Tue, 3 May 2016 19:23:22 +0000 (21:23 +0200)
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 <redacted>
src/hardware/baylibre-acme/protocol.c

index c09e91aad58699116e381c4e45c74f11d3d8947b..f6ceaf5d208cc92f428e6135d7ae740adbbd3673 100644 (file)
@@ -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;
        }