diff options
-rw-r--r-- | src/jv_aux.c | 1 | ||||
-rw-r--r-- | tests/jq.test | 7 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/jv_aux.c b/src/jv_aux.c index 0a06117e..a08ca88e 100644 --- a/src/jv_aux.c +++ b/src/jv_aux.c @@ -417,6 +417,7 @@ jv jv_setpath(jv root, jv path, jv value) { // to null first. root = jv_set(root, jv_copy(pathcurr), jv_null()); if (!jv_is_valid(root)) { + jv_free(subroot); jv_free(pathcurr); jv_free(pathrest); jv_free(value); diff --git a/tests/jq.test b/tests/jq.test index eabf836f..bde6c0a3 100644 --- a/tests/jq.test +++ b/tests/jq.test @@ -2169,3 +2169,10 @@ try ltrimstr("x") catch "x", try rtrimstr("x") catch "x" | "ok" ["ko","endswith() requires string inputs"] ["ok",""] ["ko","endswith() requires string inputs"] + + +# oss-fuzz #66061: setpath/2 leaks when indexing array with array + +try ["OK", setpath([[1]]; 1)] catch ["KO", .] +[] +["KO","Cannot update field at array index of array"] |