From 2356381b1b45d0a2e8244ffb5fb25b0d540b4c58 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 29 Apr 2026 13:08:30 -0400 Subject: ini_section_create: realloc * Fix sizeof * Remove pointless else * Free on error --- src/lib/core/ini.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/lib') diff --git a/src/lib/core/ini.c b/src/lib/core/ini.c index d93e048..f90cb2b 100644 --- a/src/lib/core/ini.c +++ b/src/lib/core/ini.c @@ -400,12 +400,12 @@ int ini_setval(struct INIFILE **ini, unsigned type, char *section_name, char *ke } int ini_section_create(struct INIFILE **ini, char *key) { - struct INISection **tmp = realloc((*ini)->section, ((*ini)->section_count + 1) * sizeof(**(*ini)->section)); - if (tmp == NULL) { + struct INISection **tmp = realloc((*ini)->section, ((*ini)->section_count + 1) * sizeof (*(*ini)->section)); + if (!tmp) { + ini_free(ini); return 1; - } else { - (*ini)->section = tmp; } + (*ini)->section = tmp; (*ini)->section[(*ini)->section_count] = calloc(1, sizeof(*(*ini)->section[0])); if (!(*ini)->section[(*ini)->section_count]) { -- cgit