mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Fix rooting of external array buffer pointer (#31342)
Signed-off-by: Bentaimia Haddadi <haddadi.taym@gmail.com>
This commit is contained in:
parent
b2d2e896d6
commit
a4db81cbd0
1 changed files with 5 additions and 3 deletions
|
@ -183,16 +183,18 @@ where
|
|||
let mapping_slice_ptr =
|
||||
mapping.lock().unwrap().borrow_mut()[offset as usize..m_end as usize].as_mut_ptr();
|
||||
|
||||
let array_buffer = NewExternalArrayBuffer(
|
||||
// rooted! is needed to ensure memory safety and prevent potential garbage collection issues.
|
||||
// https://github.com/mozilla-spidermonkey/spidermonkey-embedding-examples/blob/esr78/docs/GC%20Rooting%20Guide.md#performance-tweaking
|
||||
rooted!(in(*cx) let array_buffer = NewExternalArrayBuffer(
|
||||
*cx,
|
||||
range_size as usize,
|
||||
mapping_slice_ptr as _,
|
||||
Some(free_func),
|
||||
Arc::into_raw(mapping) as _,
|
||||
);
|
||||
));
|
||||
|
||||
HeapTypedArray {
|
||||
internal: Heap::boxed(array_buffer),
|
||||
internal: Heap::boxed(*array_buffer),
|
||||
phantom: PhantomData::default(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue