check a capacity before a write - 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 dfd26e7ccf4f83f4c140503b69d773b1dbb81808
 (DIR) parent c12ff5a298eaa6efaa2651b5ea16dde24dae1147
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Tue, 15 Oct 2019 00:48:48 +0200
       
       check a capacity before a write
       
       Diffstat:
         M json2tsv.c                          |       2 ++
       
       1 file changed, 2 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/json2tsv.c b/json2tsv.c
       @@ -235,6 +235,8 @@ parsejson(void (*cb)(struct json_node *, size_t, const char *), const char **err
                        case '}':
                        case ',':
                                if (v || nodes[depth].type == TYPE_STRING) {
       +                                if (capacity(&value, &vz, v, 1) == -1)
       +                                        goto end;
                                        value[v] = '\0';
                                        cb(nodes, depth + 1, value);
                                        v = 0;