From: Alexandru Gagniuc Date: Wed, 19 Dec 2012 07:31:58 +0000 (-0600) Subject: parserc.c: Fix memory leak from g_strsplit X-Git-Tag: sigrok-cli-0.4.0~59 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=66149c2013c0009c226770e5679ae63fd834bb78;p=sigrok-cli.git parserc.c: Fix memory leak from g_strsplit g_strsplit() returns a newly-allocated NULL-terminated array of strings. g_strfreev() must be used to free it, once it is no longer needed. The probe 'names' were not freed properly, causing a "definitely lost" memory leak. Call g_strfreev(names) to properly free the memory. Signed-off-by: Alexandru Gagniuc --- diff --git a/parsers.c b/parsers.c index 1dfc16c..59b1f68 100644 --- a/parsers.c +++ b/parsers.c @@ -54,6 +54,7 @@ GSList *parse_probestring(struct sr_dev_inst *sdi, const char *probestring) ret = SR_OK; range = NULL; + names = NULL; probelist = NULL; tokens = g_strsplit(probestring, ",", 0); for (i = 0; tokens[i]; i++) { @@ -137,6 +138,9 @@ GSList *parse_probestring(struct sr_dev_inst *sdi, const char *probestring) if (range) g_strfreev(range); + if (names) + g_strfreev(names); + if (ret != SR_OK) { g_slist_free(probelist); probelist = NULL;