diff options
| author | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-04-29 13:16:37 -0400 |
|---|---|---|
| committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2026-05-11 15:50:48 -0400 |
| commit | 8842af477c702f7f9bb5953e152407149e3e1d78 (patch) | |
| tree | 2cea01cfa68a3d0d149adbb869ecdbc7e9aa675e /src | |
| parent | 9d37911e194e526fa164dab43a0d4546fa14ddd2 (diff) | |
| download | stasis-8842af477c702f7f9bb5953e152407149e3e1d78.tar.gz | |
ini_open: return on error
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/core/ini.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/lib/core/ini.c b/src/lib/core/ini.c index ba3ab63..495ee93 100644 --- a/src/lib/core/ini.c +++ b/src/lib/core/ini.c @@ -545,10 +545,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'; @@ -621,7 +630,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)); |
