From 5b7191ed7c27a7c2d0824b8e9d60efe3207be629 Mon Sep 17 00:00:00 2001 From: Martin Lund Date: Sat, 4 Jun 2022 20:36:45 +0200 Subject: [PATCH] Fix configfile memory leaks --- src/configfile.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/configfile.c b/src/configfile.c index 01cc2c8..2f0f965 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -236,18 +236,26 @@ static int resolve_config_file(void) return 0; } + free(c->path); + asprintf(&c->path, "%s/.config/tio/tiorc", getenv("HOME")); if (!access(c->path, F_OK)) { return 0; } + free(c->path); + asprintf(&c->path, "%s/.tiorc", getenv("HOME")); if (!access(c->path, F_OK)) { return 0; } + free(c->path); + + c->path = NULL; + return -EINVAL; } @@ -333,7 +341,7 @@ void config_file_print() tio_printf(" Path: %s", c->path); if (c->section_name != NULL) { - tio_printf(" Active config section: %s", c->section_name); + tio_printf(" Active sub-configuration: %s", c->section_name); } } }