Files
jq/src
Thalha Ahmed 82c09066b1 Add jv_mem_reallocarray for overflow-safe array reallocation (#3596)
The pending buffer that jv_free grows while releasing nested arrays and
objects computes its size as cap * sizeof(jv), which wraps around on
32-bit platforms once more than 2^27 values are pending, so realloc
returns an undersized buffer that is then written past its end.

Add jv_mem_reallocarray(ptr, nmemb, size), which aborts via
memory_exhausted() when nmemb * size overflows or the allocation fails,
and use it for the three pending buffer growth sites in jv_free. Also
use it for the parser value stack and the module library entry table,
and add an equivalent check to the Windows pthread_setspecific
emulation; these sizes are bounded in practice, but the helper keeps
the multiplication checked at every array reallocation.
2026-12-06 14:06:14 +09:00
..
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…