Skip to content

Commit 1cb3a66

Browse files
committed
get this may return a null pointer
1 parent 24fe9e8 commit 1cb3a66

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

phper/src/values.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,13 @@ impl ExecuteData {
187187
/// Gets associated mutable `$this` object if exists.
188188
pub fn get_this_mut(&mut self) -> Option<&mut ZObj> {
189189
unsafe {
190-
let val = ZVal::from_mut_ptr(phper_get_this(&mut self.inner));
191-
val.as_mut_z_obj()
190+
let ptr = phper_get_this(&mut self.inner);
191+
if ptr.is_null() {
192+
None
193+
} else {
194+
let val = ZVal::from_mut_ptr(ptr);
195+
val.as_mut_z_obj()
196+
}
192197
}
193198
}
194199

0 commit comments

Comments
 (0)