From 9946aa155696f908ff00e3dbcc5bb66be5664a64 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 29 Apr 2026 13:16:37 -0400 Subject: ini_open: return on error --- src/lib/core/ini.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lib/core/ini.c b/src/lib/core/ini.c index 2cb0ee4..d4e6052 100644 --- a/src/lib/core/ini.c +++ b/src/lib/core/ini.c @@ -542,10 +542,19 @@ struct INIFILE *ini_open(const char *filename) { return NULL; } - ini_section_init(&ini); + ini->section = ini_section_init(&ini); + if (!ini->section) { + ini_free(&ini); + return NULL; + } // Create an implicit section. [default] does not need to be present in the INI config - ini_section_create(&ini, "default"); + if (ini_section_create(&ini, "default")) { + SYSERROR("%s", "unable to create default section"); + ini_free(&ini); + ini = NULL; + return NULL; + } strncpy(current_section, "default", sizeof(current_section) - 1); current_section[sizeof(current_section) - 1] = '\0'; @@ -617,7 +626,11 @@ struct INIFILE *ini_open(const char *filename) { // Create new named section strip(section_name); - ini_section_create(&ini, section_name); + if (ini_section_create(&ini, section_name)) { + SYSERROR("unable to create section: %s", section_name); + ini_free(&ini); + return NULL; + } // Record the name of the section. This is used until another section is found. memset(current_section, 0, sizeof(current_section)); -- cgit