Skip to content

Commit 5015c4a

Browse files
committed
Fixed bug #65510 (5.5.2 crashes in _get_zval_ptr_ptr_var)
1 parent 0f3977b commit 5015c4a

File tree

3 files changed

+45
-8
lines changed

3 files changed

+45
-8
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ PHP NEWS
2727
- OPCache:
2828
. Fixed bug #65561 (Zend Opcache on Solaris 11 x86 needs ZEND_MM_ALIGNMENT=4).
2929
(Terry Ellison)
30+
. Fixed bug #65510 (5.5.2 crashes in _get_zval_ptr_ptr_var). (Dmitry)
3031

3132
- Openssl:
3233
. Fixed bug #64802 (openssl_x509_parse fails to parse subject properly in

ext/opcache/Optimizer/pass1_5.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
408408
int var = opline->result.var;
409409
int level = 0;
410410
zend_op *op = opline + 1;
411+
zend_op *use = NULL;
411412

412413
while (op < end) {
413414
if (op->opcode == ZEND_BEGIN_SILENCE) {
@@ -420,21 +421,36 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
420421
}
421422
}
422423
if (op->op1_type == IS_VAR && op->op1.var == var) {
423-
op->op1_type = IS_CV;
424-
op->op1.var = zend_optimizer_lookup_cv(op_array,
424+
if (use) {
425+
/* used more than once */
426+
use = NULL;
427+
break;
428+
}
429+
use = op;
430+
} else if (op->op2_type == IS_VAR && op->op2.var == var) {
431+
if (use) {
432+
/* used more than once */
433+
use = NULL;
434+
break;
435+
}
436+
use = op;
437+
}
438+
op++;
439+
}
440+
if (use) {
441+
if (use->op1_type == IS_VAR && use->op1.var == var) {
442+
use->op1_type = IS_CV;
443+
use->op1.var = zend_optimizer_lookup_cv(op_array,
425444
Z_STRVAL(ZEND_OP1_LITERAL(opline)),
426445
Z_STRLEN(ZEND_OP1_LITERAL(opline)));
427446
MAKE_NOP(opline);
428-
break;
429-
} else if (op->op2_type == IS_VAR && op->op2.var == var) {
430-
op->op2_type = IS_CV;
431-
op->op2.var = zend_optimizer_lookup_cv(op_array,
447+
} else if (use->op2_type == IS_VAR && use->op2.var == var) {
448+
use->op2_type = IS_CV;
449+
use->op2.var = zend_optimizer_lookup_cv(op_array,
432450
Z_STRVAL(ZEND_OP1_LITERAL(opline)),
433451
Z_STRLEN(ZEND_OP1_LITERAL(opline)));
434452
MAKE_NOP(opline);
435-
break;
436453
}
437-
op++;
438454
}
439455
}
440456
break;

ext/opcache/tests/bug65510.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug #65510 (5.5.2 crashes in _get_zval_ptr_ptr_var)
3+
--INI--
4+
allow_url_include=1
5+
opcache.enable=1
6+
opcache.enable_cli=1
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
--FILE--
10+
<?php
11+
function parseQuery() {
12+
$m = array("l", "a", "r", "u", "e", "n", "c", "e");
13+
foreach($m as $n) {
14+
@list($a, $b) = $n;
15+
}
16+
}
17+
parseQuery();
18+
echo "ok\n";
19+
--EXPECT--
20+
ok

0 commit comments

Comments
 (0)