Skip to content

Commit ec17343

Browse files
committed
Merge branch 'PHP-5.5'
* PHP-5.5: Fixed bug #65510 (5.5.2 crashes in _get_zval_ptr_ptr_var) Conflicts: NEWS
2 parents 462f216 + 5015c4a commit ec17343

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

ext/opcache/Optimizer/pass1_5.c

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
458458
int var = opline->result.var;
459459
int level = 0;
460460
zend_op *op = opline + 1;
461+
zend_op *use = NULL;
461462

462463
while (op < end) {
463464
if (op->opcode == ZEND_BEGIN_SILENCE) {
@@ -470,21 +471,36 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) {
470471
}
471472
}
472473
if (op->op1_type == IS_VAR && op->op1.var == var) {
473-
op->op1_type = IS_CV;
474-
op->op1.var = zend_optimizer_lookup_cv(op_array,
474+
if (use) {
475+
/* used more than once */
476+
use = NULL;
477+
break;
478+
}
479+
use = op;
480+
} else if (op->op2_type == IS_VAR && op->op2.var == var) {
481+
if (use) {
482+
/* used more than once */
483+
use = NULL;
484+
break;
485+
}
486+
use = op;
487+
}
488+
op++;
489+
}
490+
if (use) {
491+
if (use->op1_type == IS_VAR && use->op1.var == var) {
492+
use->op1_type = IS_CV;
493+
use->op1.var = zend_optimizer_lookup_cv(op_array,
475494
Z_STRVAL(ZEND_OP1_LITERAL(opline)),
476495
Z_STRLEN(ZEND_OP1_LITERAL(opline)));
477496
MAKE_NOP(opline);
478-
break;
479-
} else if (op->op2_type == IS_VAR && op->op2.var == var) {
480-
op->op2_type = IS_CV;
481-
op->op2.var = zend_optimizer_lookup_cv(op_array,
497+
} else if (use->op2_type == IS_VAR && use->op2.var == var) {
498+
use->op2_type = IS_CV;
499+
use->op2.var = zend_optimizer_lookup_cv(op_array,
482500
Z_STRVAL(ZEND_OP1_LITERAL(opline)),
483501
Z_STRLEN(ZEND_OP1_LITERAL(opline)));
484502
MAKE_NOP(opline);
485-
break;
486503
}
487-
op++;
488504
}
489505
}
490506
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)