From 9444c7c8d4108fa9beddf105a068f4a9920c049a Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Tue, 25 Nov 2025 19:02:38 +0100 Subject: [PATCH] allow an empty config file --- application/settings.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/application/settings.c b/application/settings.c index 8faf849..e66a959 100644 --- a/application/settings.c +++ b/application/settings.c @@ -125,6 +125,7 @@ int load_config(void) { CxJsonValue *value = NULL; char buf[JS_READ_BUFSIZE]; size_t r; + ret = CX_JSON_NULL_DATA; do { r = fread(buf, 1, JS_READ_BUFSIZE, cfgfile); @@ -136,11 +137,7 @@ int load_config(void) { if(ret > CX_JSON_NULL_DATA) { fprintf(stderr, "Error: cannot parse config file: %s\n", cfgfile_path); - } - - cxJsonDestroy(&parser); - - if(value) { + } else if(value) { if(value->type == CX_JSON_OBJECT) { ret = 0; uwp_config = value; @@ -148,10 +145,9 @@ int load_config(void) { } else { ret = 1; } - } else { - ret = 1; } + cxJsonDestroy(&parser); free(cfgfile_path); fclose(cfgfile); -- 2.47.3