From b8bd5f4ad452991d2a3cf78517fcba86855236ec Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Thu, 30 Apr 2026 09:45:15 -0400 Subject: init: clean up on error --- src/lib/core/ini.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/core/ini.c b/src/lib/core/ini.c index 14c6875..a510327 100644 --- a/src/lib/core/ini.c +++ b/src/lib/core/ini.c @@ -616,6 +616,7 @@ struct INIFILE *ini_open(const char *filename) { char *section_name = substring_between(line, "[]"); if (!section_name) { fprintf(stderr, "error: invalid section syntax, line %zu: '%s'\n", i + 1, line); + ini_free(&ini); return NULL; } @@ -629,6 +630,7 @@ struct INIFILE *ini_open(const char *filename) { strip(section_name); if (ini_section_create(&ini, section_name)) { SYSERROR("unable to create section: %s", section_name); + guard_free(section_name); ini_free(&ini); return NULL; } @@ -648,7 +650,7 @@ struct INIFILE *ini_open(const char *filename) { continue; } - char *operator = strchr(line, '='); + const char *operator = strchr(line, '='); // a value continuation line if (multiline_data && (startswith(line, " ") || startswith(line, "\t"))) { @@ -656,7 +658,7 @@ struct INIFILE *ini_open(const char *filename) { } if (operator) { - size_t key_len = operator - line; + const size_t key_len = operator - line; memset(key, 0, key_size); strncpy(key, line, key_len); -- cgit