check more stricly for unbalanced nodes (by type array or object) - json2tsv - JSON to TSV converter
 (HTM) git clone git://git.codemadness.org/json2tsv
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 2b96e06f28e6bd8abf9d6050f3a37de5350c76ef
 (DIR) parent ab777095d7053b3a04756ff7129e9b96d2659e05
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sat,  5 Oct 2019 10:53:51 +0200
       
       check more stricly for unbalanced nodes (by type array or object)
       
       Diffstat:
         M json2tsv.c                          |       4 +++-
       
       1 file changed, 3 insertions(+), 1 deletion(-)
       ---
 (DIR) diff --git a/json2tsv.c b/json2tsv.c
       @@ -212,7 +212,9 @@ parsejson(void (*cb)(struct json_node *, size_t, const char *))
                                        cb(nodes, depth + 1, value);
                                        v = 0;
                                }
       -                        if (!depth)
       +                        if (!depth ||
       +                            (nodes[depth - 1].type == TYPE_OBJECT && c == ']') ||
       +                            (nodes[depth - 1].type == TYPE_ARRAY && c == '}'))
                                        fatal("unbalanced nodes\n");
        
                                if (c == ']' || c == '}') {