From a6435ecaa9b6f3c6ad0baed62a5725eb1de6e798 Mon Sep 17 00:00:00 2001 From: Nathaniel Walizer Date: Mon, 20 Jan 2025 17:58:10 -0800 Subject: [PATCH] Fix NULL string crash when writing INI files --- src/ini.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ini.c b/src/ini.c index 12d0493..2edf437 100644 --- a/src/ini.c +++ b/src/ini.c @@ -68,8 +68,10 @@ static int _write_ini_file(FILE* file, const ini_datum* schema, if (ini_string == schema->type) { const char* str = *(char**)ptr; - if (!needs_quotes(str)) fputs(str, file); - else fprintf(file, "\"%s\"", str); + if (NULL != str) { + if (!needs_quotes(str)) fputs(str, file); + else fprintf(file, "\"%s\"", str); + } } else if (ini_integer == schema->type) { fprintf(file, "%d", *(uint32_t*)ptr);