fix(format): return whole VL sequences from read_vl_bytes

read_vl_bytes cut each element to the reference's length field, which
counts sequence elements, not bytes: a VL int32 [1, 2, 3] came back as
3 bytes. Return the whole global-heap object, which is element count x
base size bytes. No in-tree caller depended on the old behaviour.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
osobh
2026-09-25 21:08:37 -05:00
co-authored by Claude Opus 5.5
parent c8c2930fc0
commit 2f252df084
2 changed files with 71 additions and 3 deletions
+10 -3
View File
@@ -148,7 +148,12 @@ pub fn read_vl_strings(
Ok(result)
}
/// Resolve VL byte sequences from raw data.
/// Resolve VL sequences from raw data, returning each element's bytes.
///
/// Each element is the sequence's full encoding — element count × base type
/// size bytes, in the base type's byte order — so a sequence of `i32` yields
/// four bytes per value. Decode it with the base type (e.g.
/// [`crate::data_read::read_as_i64`]).
pub fn read_vl_bytes(
file_data: &[u8],
raw_data: &[u8],
@@ -177,8 +182,10 @@ pub fn read_vl_bytes(
},
)?;
let len = (vl.length as usize).min(obj.data.len());
result.push(obj.data[..len].to_vec());
// The heap object holds the whole sequence. `vl.length` counts
// elements, not bytes, so it is only the byte length when the base
// type is one byte wide.
result.push(obj.data.clone());
}
Ok(result)