diff --git a/src/jv_aux.c b/src/jv_aux.c index 0a06117e91..a08ca88e72 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 eabf836fa0..bde6c0a33c 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"]