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 <l...@metafoo.de>
---
 src/hardware/baylibre-acme/protocol.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/hardware/baylibre-acme/protocol.c 
b/src/hardware/baylibre-acme/protocol.c
index 0bef0b2..fdc16c8 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;
        }
 
-- 
2.1.4


------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
sigrok-devel mailing list
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to