Conversation
There was a problem hiding this comment.
C API returns dangling pointers for typed array values
The json_api_next function returns raw pointers to values via .as_ref(). For typed homogeneous arrays (i8, i16, f16, etc.), the ijson library returns ArrayIterItem::Owned values which become ValueRef::Owned in the results iterator. When json_api_next returns a pointer to these owned values, the pointer points to data stored inside the iterator. After json_api_free_iter is called, this data is freed and the pointer becomes dangling. The previous API stored Vec<&'a V> (borrowed references) where pointers remained valid as long as the JSON document was alive. This change breaks the C API contract and can cause use-after-free when C code uses values from typed arrays after freeing the iterator.
redis_json/src/c_api.rs#L296-L306
RedisJSON/redis_json/src/c_api.rs
Lines 296 to 306 in 3c7c7ce
json_path/src/json_node.rs#L137-L144
RedisJSON/json_path/src/json_node.rs
Lines 137 to 144 in 3c7c7ce
Note
Modernizes core JSON handling and release pipeline with compatibility updates.
ValueRefand refactorsselect_value/json_pathto support owned/borrowed values; adds operations over homogeneous numeric arrays; bumps crate to8.4.1and updatespack/ramp.yml(compatible_redis_version=8.4, addsasm).allocJson/freeJson), changesgetAt/nextKeyValueto write into provided pointers and return status codes; updates iterators to handle owned values.1.88, updates/pins deps (newijsonrev,home=0.5.11), largeCargo.lockrefresh.beta-versionpath producing SNAPSHOT-only artifacts; enhances S3 uploads (beta copies outsidesnapshots/); tweaks workflows (ARM flow renamed/expanded, macOS/alpine aligned).Written by Cursor Bugbot for commit 3c7c7ce. This will update automatically on new commits. Configure here.