diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-06-09 16:30:46 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-06-09 16:33:33 +0200 |
commit | e56e53a59dc1257210939f99975b6617a77e63e4 (patch) | |
tree | 69cc6912a58d9e1ae52847a36dea6d3be0369539 /Zend/zend_execute_API.c | |
parent | 257dbb04501391e0ac57e66aebe2e4d25dcc5c91 (diff) | |
download | php-git-e56e53a59dc1257210939f99975b6617a77e63e4.tar.gz |
Back up fake_scope in zend_call_function
We regularly find new places where we forgot to reset fake_scope.
Instead of having to handle this for each caller of zend_call_function()
and similar APIs, handle it directly in zend_call_function().
Diffstat (limited to 'Zend/zend_execute_API.c')
-rw-r--r-- | Zend/zend_execute_API.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c index c5626a0df3..b650444d1c 100644 --- a/Zend/zend_execute_API.c +++ b/Zend/zend_execute_API.c @@ -646,6 +646,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / zend_function *func; uint32_t call_info; void *object_or_called_scope; + zend_class_entry *orig_fake_scope; ZVAL_UNDEF(fci->retval); @@ -791,6 +792,8 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / ZEND_ADD_CALL_FLAG(call, call_info); } + orig_fake_scope = EG(fake_scope); + EG(fake_scope) = NULL; if (func->type == ZEND_USER_FUNCTION) { int call_via_handler = (func->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0; const zend_op *current_opline_before_exception = EG(opline_before_exception); @@ -841,6 +844,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) / } } } + EG(fake_scope) = orig_fake_scope; zend_vm_stack_free_call_frame(call); @@ -914,7 +918,6 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string * zend_string *lc_name; zend_fcall_info fcall_info; zend_fcall_info_cache fcall_cache; - zend_class_entry *orig_fake_scope; if (key) { lc_name = key; @@ -1005,14 +1008,11 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, zend_string * fcall_cache.called_scope = NULL; fcall_cache.object = NULL; - orig_fake_scope = EG(fake_scope); - EG(fake_scope) = NULL; zend_exception_save(); if ((zend_call_function(&fcall_info, &fcall_cache) == SUCCESS) && !EG(exception)) { ce = zend_hash_find_ptr(EG(class_table), lc_name); } zend_exception_restore(); - EG(fake_scope) = orig_fake_scope; zval_ptr_dtor(&args[0]); zval_ptr_dtor_str(&fcall_info.function_name); |