Skip to content

Commit ccdda69

Browse files
committed
JIT: Fixed usage of incorrect specialized zval destructor
1 parent ed8ec9d commit ccdda69

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1383,7 +1383,8 @@ static void* dasm_labels[zend_lb_MAX];
13831383
// zval should be in FCARG1a
13841384
|.macro ZVAL_DTOR_FUNC, var_info, opline // arg1 must be in FCARG1a
13851385
|| do {
1386-
|| if (has_concrete_type((var_info) & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_INDIRECT))) {
1386+
|| if (!((var_info) & MAY_BE_GUARD)
1387+
|| && has_concrete_type((var_info) & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_INDIRECT))) {
13871388
|| zend_uchar type = concrete_type((var_info) & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE));
13881389
|| if (type == IS_STRING && !ZEND_DEBUG) {
13891390
| EXT_CALL _efree, r0
@@ -15325,6 +15326,7 @@ static zend_bool zend_jit_fetch_reference(dasm_State **Dst, const zend_op *oplin
1532515326
var_info &= ~MAY_BE_REF;
1532615327
*var_info_ptr = var_info;
1532715328
}
15329+
*var_info_ptr |= MAY_BE_GUARD; /* prevent generation of specialized zval dtor */
1532815330

1532915331
return 1;
1533015332
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
JIT FETCH_DIM_R: 007
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.file_update_protection=0
7+
opcache.jit_buffer_size=1M
8+
--FILE--
9+
<?php
10+
function &test() {
11+
$var = [0];
12+
return $var;
13+
}
14+
var_dump(test()[0]);
15+
?>
16+
--EXPECT--
17+
int(0)

0 commit comments

Comments
 (0)