Skip to content

Commit 3056f4c

Browse files
author
Florian Engelhardt
committed
fix segfault in ZEND_BIND_STATIC
In case a `ZEND_BIND_STATIC` is being executed, while the current chunk is full, the `zend_array_dup()` call will trigger a OOM in ZendMM which will crash, as the opline might be a dangling pointer.
1 parent 87107f8 commit 3056f4c

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

Zend/zend_vm_def.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8788,6 +8788,8 @@ ZEND_VM_HANDLER(183, ZEND_BIND_STATIC, CV, UNUSED, REF)
87888788

87898789
variable_ptr = GET_OP1_ZVAL_PTR_PTR_UNDEF(BP_VAR_W);
87908790

8791+
SAVE_OPLINE();
8792+
87918793
ht = ZEND_MAP_PTR_GET(EX(func)->op_array.static_variables_ptr);
87928794
if (!ht) {
87938795
ht = zend_array_dup(EX(func)->op_array.static_variables);
@@ -8797,7 +8799,6 @@ ZEND_VM_HANDLER(183, ZEND_BIND_STATIC, CV, UNUSED, REF)
87978799

87988800
value = (zval*)((char*)ht->arData + (opline->extended_value & ~(ZEND_BIND_REF|ZEND_BIND_IMPLICIT|ZEND_BIND_EXPLICIT)));
87998801

8800-
SAVE_OPLINE();
88018802
if (opline->extended_value & ZEND_BIND_REF) {
88028803
if (Z_TYPE_P(value) == IS_CONSTANT_AST) {
88038804
if (UNEXPECTED(zval_update_constant_ex(value, EX(func)->op_array.scope) != SUCCESS)) {

Zend/zend_vm_execute.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48471,6 +48471,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BIND_STATIC_SPEC_CV_UNUSED_HAN
4847148471

4847248472
variable_ptr = EX_VAR(opline->op1.var);
4847348473

48474+
SAVE_OPLINE();
48475+
4847448476
ht = ZEND_MAP_PTR_GET(EX(func)->op_array.static_variables_ptr);
4847548477
if (!ht) {
4847648478
ht = zend_array_dup(EX(func)->op_array.static_variables);
@@ -48480,7 +48482,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_BIND_STATIC_SPEC_CV_UNUSED_HAN
4848048482

4848148483
value = (zval*)((char*)ht->arData + (opline->extended_value & ~(ZEND_BIND_REF|ZEND_BIND_IMPLICIT|ZEND_BIND_EXPLICIT)));
4848248484

48483-
SAVE_OPLINE();
4848448485
if (opline->extended_value & ZEND_BIND_REF) {
4848548486
if (Z_TYPE_P(value) == IS_CONSTANT_AST) {
4848648487
if (UNEXPECTED(zval_update_constant_ex(value, EX(func)->op_array.scope) != SUCCESS)) {

0 commit comments

Comments
 (0)