Skip to content

runtime: Loosened restriction on reading arrays of exact length #2140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions runtime/wasm/src/asc_abi/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ impl<T: AscValue> ArrayBuffer<T> {
fn get(&self, byte_offset: u32, length: u32) -> Result<Vec<T>, DeterministicHostError> {
let length = length as usize;
let byte_offset = byte_offset as usize;

self.content[byte_offset..]
.chunks(size_of::<T>())
.take(length)
.map(T::from_asc_bytes)
.collect()

// TODO: This code is preferred as it validates the length of the array.
// But, some existing subgraphs were found to break when this was added.
// This needs to be root caused
/*
let range = byte_offset..byte_offset + length * size_of::<T>();
self.content
.get(range)
Expand All @@ -64,6 +75,7 @@ impl<T: AscValue> ArrayBuffer<T> {
.chunks_exact(size_of::<T>())
.map(|bytes| T::from_asc_bytes(bytes))
.collect()
*/
}
}

Expand Down