From 66149c2013c0009c226770e5679ae63fd834bb78 Mon Sep 17 00:00:00 2001 From: Alexandru Gagniuc Date: Wed, 19 Dec 2012 01:31:58 -0600 Subject: [PATCH 1/1] 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 --- parsers.c | 4 ++++ 1 file changed, 4 insertions(+) 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; -- 2.30.2