Skip to content

Commit c8c1df0

Browse files
committed
Fix construction of native classes and any class with properties
1 parent ab2af45 commit c8c1df0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/types/object.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,18 @@ impl ZendObject {
4141
// SAFETY: Using emalloc to allocate memory inside Zend arena. Casting `ce` to
4242
// `*mut` is valid as the function will not mutate `ce`.
4343
unsafe {
44-
let ptr = zend_objects_new(ce as *const _ as *mut _);
45-
object_properties_init(ptr, ce as *const _ as *mut _);
44+
let ptr = match ce.__bindgen_anon_2.create_object {
45+
None => {
46+
let ptr = zend_objects_new(ce as *const _ as *mut _);
47+
if ptr.is_null() {
48+
panic!("Failed to allocate memory for Zend object")
49+
}
50+
object_properties_init(ptr, ce as *const _ as *mut _);
51+
ptr
52+
},
53+
Some(v) => v(ce as *const _ as *mut _)
54+
};
55+
4656
ZBox::from_raw(
4757
ptr.as_mut()
4858
.expect("Failed to allocate memory for Zend object"),

0 commit comments

Comments
 (0)