From 53e9c36cd94fae193a4fcbb879b93db31a4906c3 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 16 Mar 2021 10:38:04 +0100 Subject: Add sanity check for type of read_property return value If an internal class overrides read_property and declared property types, make sure that the returned value matches the declared type (in debug builds). --- Zend/zend_vm_def.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Zend/zend_vm_def.h') diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index a81ff958f2..39f1216958 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -2106,6 +2106,11 @@ ZEND_VM_C_LABEL(fetch_obj_r_fast_copy): } retval = zobj->handlers->read_property(zobj, name, BP_VAR_R, cache_slot, EX_VAR(opline->result.var)); +#if ZEND_DEBUG + if (!EG(exception) && zobj->handlers->read_property != zend_std_read_property) { + zend_verify_internal_read_property_type(zobj, name, retval); + } +#endif if (OP2_TYPE != IS_CONST) { zend_tmp_string_release(tmp_name); -- cgit v1.2.1