Skip to content

Commit 8360abd

Browse files
committed
Add missing nullptr check for cb_free_type_list in Rust API
1 parent a9a002c commit 8360abd

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

rust/src/architecture.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -2954,9 +2954,12 @@ where
29542954
A: 'static + Architecture<Handle = CustomArchitectureHandle<A>> + Send + Sync,
29552955
{
29562956
let _custom_arch = unsafe { &*(ctxt as *mut A) };
2957-
let boxed_types = unsafe { Box::from_raw(std::ptr::slice_from_raw_parts_mut(tl, count)) };
2958-
for ty in boxed_types {
2959-
Conf::<Ref<Type>>::free_raw(ty);
2957+
if !tl.is_null() {
2958+
let boxed_types =
2959+
unsafe { Box::from_raw(std::ptr::slice_from_raw_parts_mut(tl, count)) };
2960+
for ty in boxed_types {
2961+
Conf::<Ref<Type>>::free_raw(ty);
2962+
}
29602963
}
29612964
}
29622965

0 commit comments

Comments
 (0)