aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2026-04-29 13:08:30 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2026-05-11 15:50:48 -0400
commite9ecb44bbd84c2896fcee35ead68baef9b8d1cc3 (patch)
treebd287246e2a0b9a80a94d349a76dafefd5052403
parente47e37c9537cc5ad215344262ecdda6f6c56b6d9 (diff)
downloadstasis-e9ecb44bbd84c2896fcee35ead68baef9b8d1cc3.tar.gz
ini_section_create: realloc
* Fix sizeof * Remove pointless else * Free on error
-rw-r--r--src/lib/core/ini.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lib/core/ini.c b/src/lib/core/ini.c
index 3c52312..07206ac 100644
--- a/src/lib/core/ini.c
+++ b/src/lib/core/ini.c
@@ -403,12 +403,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]) {