Skip to content
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

isolate->GetCppHeap() can return nullptr if no heap is attached #1385

Merged
merged 2 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion examples/cppgc-object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn main() {
let obj = templ.new_instance(scope).unwrap();

let member = v8::cppgc::make_garbage_collected(
scope.get_cpp_heap(),
scope.get_cpp_heap().unwrap(),
Box::new(Wrappable {
trace_count: Cell::new(0),
id,
Expand Down
4 changes: 2 additions & 2 deletions src/isolate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1100,8 +1100,8 @@
}
}

pub fn get_cpp_heap(&mut self) -> &Heap {
unsafe { &*v8__Isolate__GetCppHeap(self) }
pub fn get_cpp_heap(&mut self) -> Option<&Heap> {
unsafe { v8__Isolate__GetCppHeap(self).as_ref().map(|h| &*h) }

Check failure on line 1104 in src/isolate.rs

View workflow job for this annotation

GitHub Actions / release x86_64-unknown-linux-gnu

deref on an immutable reference
}

#[inline(always)]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cppgc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn cppgc_object_wrap() {
let obj = templ.new_instance(scope).unwrap();

let member =
v8::cppgc::make_garbage_collected(scope.get_cpp_heap(), Box::new(Wrap));
v8::cppgc::make_garbage_collected(scope.get_cpp_heap().unwrap(), Box::new(Wrap));

obj.set_aligned_pointer_in_internal_field(
0,
Expand Down
Loading