Skip to content

Commit 4f52fe2

Browse files
authored
Run Dart finalizer callback for external types when they fail to post
Fix ZeroCopyBuffer memory leak related to discussion in shekohex#6
1 parent e4a0626 commit 4f52fe2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ impl Isolate {
123123
let result = func(self.port, ptr);
124124
// free the object
125125
let boxed_obj = Box::from_raw(ptr);
126+
if !result && boxed_obj.ty == DartCObjectType::DartExternalTypedData {
127+
(boxed_obj.value.as_external_typed_data.callback)(boxed_obj.value.as_external_typed_data.data as *mut c_void, boxed_obj.value.as_external_typed_data.peer);
128+
}
126129
drop(boxed_obj);
127130
// I like that dance haha
128131
result

0 commit comments

Comments
 (0)