summaryrefslogtreecommitdiff
path: root/ext/opcache/Optimizer/zend_optimizer.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2017-10-04 16:38:55 +0300
committerDmitry Stogov <dmitry@zend.com>2017-10-04 16:38:55 +0300
commitb6e34eaf04c5fc692f7c1aff77647f4961c99748 (patch)
treecb2f8c0a17cb031fe180a53bc1941d8078ad40f3 /ext/opcache/Optimizer/zend_optimizer.c
parentc935b832dc5134ba37752af1049f4e730f5e0400 (diff)
downloadphp-git-b6e34eaf04c5fc692f7c1aff77647f4961c99748.tar.gz
Fixed rarely possible use-after-free
Diffstat (limited to 'ext/opcache/Optimizer/zend_optimizer.c')
-rw-r--r--ext/opcache/Optimizer/zend_optimizer.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c
index 08ac084713..c5f62b3172 100644
--- a/ext/opcache/Optimizer/zend_optimizer.c
+++ b/ext/opcache/Optimizer/zend_optimizer.c
@@ -1027,6 +1027,19 @@ int zend_optimize_script(zend_script *script, zend_long optimization_level, zend
ZEND_SET_FUNC_INFO(call_graph.op_arrays[i], NULL);
}
+ ZEND_HASH_FOREACH_PTR(&script->class_table, ce) {
+ ZEND_HASH_FOREACH_STR_KEY_PTR(&ce->function_table, name, op_array) {
+ if (op_array->scope != ce) {
+ zend_op_array *orig_op_array;
+ if ((orig_op_array = zend_hash_find_ptr(&op_array->scope->function_table, name)) != NULL) {
+ HashTable *ht = op_array->static_variables;
+ *op_array = *orig_op_array;
+ op_array->static_variables = ht;
+ }
+ }
+ } ZEND_HASH_FOREACH_END();
+ } ZEND_HASH_FOREACH_END();
+
zend_arena_release(&ctx.arena, checkpoint);
} else
#endif