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 <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2016-04-29 10:25:18 +02:00
parent 7b6072d354
commit a64fec2b8e
1 changed files with 3 additions and 0 deletions

View 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;
}