diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-29 13:08:30 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-29 13:08:30 -0400 |
| commit | 2356381b1b45d0a2e8244ffb5fb25b0d540b4c58 (patch) | |
| tree | dc7baebd85e4dd081a01a1b4867450cfa16e8074 | |
| parent | 3e7737c5ec8ba2107a4f116b16baf7a8d75f1f81 (diff) | |
| download | stasis-2356381b1b45d0a2e8244ffb5fb25b0d540b4c58.tar.gz | |
ini_section_create: realloc
* Fix sizeof
* Remove pointless else
* Free on error
| -rw-r--r-- | src/lib/core/ini.c | 8 |
1 files changed, 4 insertions, 4 deletions
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]) { |
