From: Olaf Wintermann Date: Tue, 25 Nov 2025 18:02:38 +0000 (+0100) Subject: allow an empty config file X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=9444c7c8d4108fa9beddf105a068f4a9920c049a;p=uwplayer.git allow an empty config file --- 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);