summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2017-11-16 16:24:04 +0100
committerHarald Welte <laforge@gnumonks.org>2017-11-18 10:30:57 +0000
commit00393e1a042df7d8d5fc59d6443502b6bd82c520 (patch)
tree1440c72da281b87c935ae0066f0e721d7424b5fb /src
parentb93f60f7cd4bebbe6c26a456ea0b394fcafc731f (diff)
memleak: osmo_config_list_parse: getline() needs free also on error
Helps fix sanitizer build on debian 9. Change-Id: Iddf0a6cc733cd81d5f6c1eb62fc079ad319db119
Diffstat (limited to 'src')
-rw-r--r--src/msgfile.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/msgfile.c b/src/msgfile.c
index 278b9a7d..1f11aa60 100644
--- a/src/msgfile.c
+++ b/src/msgfile.c
@@ -119,9 +119,10 @@ struct osmo_config_list *osmo_config_list_parse(void *ctx, const char *filename)
line = NULL;
while (getline(&line, &n, file) != -1) {
handle_line(entries, line);
- free(line);
- line = NULL;
}
+ /* The returned getline() buffer needs to be freed even if it failed. It can simply re-use the
+ * buffer that was allocated on the first call. */
+ free(line);
fclose(file);
return entries;