Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jv_setpath: fix leak when indexing an array with an array
arrays[arrays] is a special case of "INDEX" that actually returns an array containing the indices in which the array that is being indexed contains the start of the key array. So array keys, for array values, are a kind of key that can be "got", but not "set". jv_setpath() was not freeing the value it "got" from indexing that key, in case the following "set" on that key failed, resulting in a leak. $ ./jq -n '[] | setpath([[1]]; 1)' jq: error (at <unknown>): Cannot update field at array index of array ================================================================= ==953483==ERROR: LeakSanitizer: detected memory leaks Direct leak of 272 byte(s) in 1 object(s) allocated from: #0 0x725f4d4e1359 in __interceptor_malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69 jqlang#1 0x5ec17b1a7438 in jv_mem_alloc src/jv_alloc.c:141 SUMMARY: AddressSanitizer: 272 byte(s) leaked in 1 allocation(s). Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66061
- Loading branch information