check a capacity before a write - json2tsv - JSON to TSV converter | |
git clone git://git.codemadness.org/json2tsv | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit dfd26e7ccf4f83f4c140503b69d773b1dbb81808 | |
parent c12ff5a298eaa6efaa2651b5ea16dde24dae1147 | |
Author: Hiltjo Posthuma <[email protected]> | |
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(-) | |
--- | |
diff --git a/json2tsv.c b/json2tsv.c | |
@@ -235,6 +235,8 @@ parsejson(void (*cb)(struct json_node *, size_t, const char… | |
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; |