Skip to content

Commit 69a4b13

Browse files
committed
Fix use after free for variables with integer names
1 parent 4d6fb5e commit 69a4b13

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Variable with integer name
3+
--FILE--
4+
<?php
5+
6+
${10} = 42;
7+
var_dump(${10});
8+
9+
?>
10+
--EXPECT--
11+
int(42)

Zend/zend_compile.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,6 +1950,9 @@ static int zend_try_compile_cv(znode *result, zend_ast *ast) /* {{{ */
19501950
result->op_type = IS_CV;
19511951
result->u.op.var = lookup_cv(CG(active_op_array), name);
19521952

1953+
/* lookup_cv may be using another zend_string instance */
1954+
name = CG(active_op_array)->vars[EX_VAR_TO_NUM(result->u.op.var)];
1955+
19531956
if (zend_string_equals_literal(name, "this")) {
19541957
CG(active_op_array)->this_var = result->u.op.var;
19551958
}

0 commit comments

Comments
 (0)