Skip to content

Commit 3688aac

Browse files
committed
Check instance_of() so subclasses also work
1 parent fbb0b41 commit 3688aac

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/types/class_object.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl<T: RegisteredClass> ZendClassObject<T> {
167167
(ptr as *mut Self).as_mut()?
168168
};
169169

170-
if ptr.std.is_instance::<T>() {
170+
if ptr.std.instance_of(T::get_metadata().ce()) {
171171
Some(ptr)
172172
} else {
173173
None

src/zend/handlers.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ impl ZendObjectHandlers {
5252
}
5353

5454
unsafe extern "C" fn free_obj<T: RegisteredClass>(object: *mut ZendObject) {
55-
object
55+
let obj = object
5656
.as_mut()
5757
.and_then(|obj| ZendClassObject::<T>::from_zend_obj_mut(obj))
58-
.map(|obj|ptr::drop_in_place(&mut obj.obj));
58+
.expect("Invalid object pointer given for `free_obj`");
5959

6060
// Manually drop the object as we don't want to free the underlying memory.
61-
61+
ptr::drop_in_place(&mut obj.obj);
6262

6363
zend_object_std_dtor(object)
6464
}

0 commit comments

Comments
 (0)