]> uap-core.de Git - uwplayer.git/commitdiff
fix json parser usage
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 17 Nov 2025 17:51:01 +0000 (18:51 +0100)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 17 Nov 2025 17:51:01 +0000 (18:51 +0100)
application/Makefile
application/settings.c

index 6569066f2f258f57363b75bf3ea135b06cab41cd..31fba461e116978b5e6405de17c6095f340282be 100644 (file)
@@ -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
index e60022f123df18a153ff60ba4d62ec9c03f2ec2a..bdba27feeb8607481a48deb9fe816c809df05b26 100644 (file)
@@ -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) {