From 5f762782ca2a8f2e0b85c5b07a25f3c8be116cdf Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Mon, 17 Nov 2025 18:51:01 +0100 Subject: [PATCH] fix json parser usage --- application/Makefile | 1 - application/settings.c | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/application/Makefile b/application/Makefile index 6569066..31fba46 100644 --- a/application/Makefile +++ b/application/Makefile @@ -38,7 +38,6 @@ SRC += window.c SRC += player.c SRC += settings.c SRC += utils.c -SRC += json.c SRC += Sidebar.c SRC += xdnd.c SRC += playlist.c diff --git a/application/settings.c b/application/settings.c index e60022f..bdba27f 100644 --- a/application/settings.c +++ b/application/settings.c @@ -116,7 +116,6 @@ int load_config(void) { char *cfgfile_path = util_concat_path(uwp_config_dir, UWP_CONFIG_FILE); FILE *cfgfile = fopen(cfgfile_path, "r"); - free(cfgfile_path); int ret = 0; if(cfgfile) { @@ -126,8 +125,11 @@ int load_config(void) { CxJsonValue *value = NULL; char buf[JS_READ_BUFSIZE]; size_t r; - - while((ret = cxJsonNext(&parser, &value)) == CX_JSON_INCOMPLETE_DATA) { + while((ret = cxJsonNext(&parser, &value)) != CX_JSON_NO_ERROR) { + if(ret > CX_JSON_NULL_DATA) { + fprintf(stderr, "Error: cannot parse config file: %s\n", cfgfile_path); + break; // error + } r = fread(buf, 1, JS_READ_BUFSIZE, cfgfile); if(r == 0) { break; @@ -150,6 +152,7 @@ int load_config(void) { } + free(cfgfile_path); fclose(cfgfile); if(ret) { -- 2.47.3