Skip to content

Commit f31ba7c

Browse files
committed
Fixed bug #76477 (Opcache causes empty return value)
1 parent dad8bd5 commit f31ba7c

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ PHP NEWS
88
- EXIF:
99
. Fixed bug #76409 (heap use after free in _php_stream_free). (cmb)
1010

11+
- Opcache:
12+
. Fixed bug #76477 (Opcache causes empty return value).
13+
(Nikita, Laruence)
14+
1115
- ZIP:
1216
. Fixed bug #76461 (OPSYS_Z_CPM defined instead of OPSYS_CPM).
1317
(Dennis Birkholz, Remi)

ext/opcache/Optimizer/zend_call_graph.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_f
155155
case ZEND_SEND_REF:
156156
case ZEND_SEND_VAR_NO_REF:
157157
case ZEND_SEND_VAR_NO_REF_EX:
158+
case ZEND_SEND_USER:
158159
if (call_info) {
159160
uint32_t num = opline->op2.num;
160161

@@ -165,9 +166,11 @@ int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_f
165166
}
166167
break;
167168
case ZEND_SEND_ARRAY:
168-
case ZEND_SEND_USER:
169169
case ZEND_SEND_UNPACK:
170170
/* TODO: set info about var_arg call ??? */
171+
if (call_info) {
172+
call_info->num_args = -1;
173+
}
171174
break;
172175
}
173176
opline++;

ext/opcache/Optimizer/zend_func_info.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
+----------------------------------------------------------------------+
1717
*/
1818

19-
/* $Id:$ */
20-
2119
#include "php.h"
2220
#include "zend_compile.h"
2321
#include "zend_extensions.h"
@@ -79,9 +77,11 @@ static uint32_t zend_strlen_info(const zend_call_info *call_info, const zend_ssa
7977
tmp |= MAY_BE_LONG | FUNC_MAY_WARN | MAY_BE_NULL;
8078
}
8179
return tmp;
82-
} else {
80+
} else if (call_info->num_args != -1) {
8381
/* warning, and returns NULL */
8482
return FUNC_MAY_WARN | MAY_BE_NULL;
83+
} else {
84+
return MAY_BE_LONG | FUNC_MAY_WARN | MAY_BE_NULL;
8585
}
8686
}
8787

@@ -90,9 +90,11 @@ static uint32_t zend_dechex_info(const zend_call_info *call_info, const zend_ssa
9090
if (call_info->caller_init_opline->extended_value == (uint32_t)call_info->num_args &&
9191
call_info->num_args == 1) {
9292
return MAY_BE_RC1 | MAY_BE_STRING;
93-
} else {
93+
} else if (call_info->num_args != -1) {
9494
/* warning, and returns NULL */
9595
return FUNC_MAY_WARN | MAY_BE_NULL;
96+
} else {
97+
return FUNC_MAY_WARN | MAY_BE_RC1 | MAY_BE_STRING | MAY_BE_NULL;
9698
}
9799
}
98100

ext/opcache/tests/bug76477.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #76477 (Opcache causes empty return value)
3+
--INI--
4+
opcache.enable=1
5+
opcache.enable_cli=1
6+
opcache.optimization_level=-1
7+
--SKIPIF--
8+
<?php require_once('skipif.inc'); ?>
9+
--FILE--
10+
<?php
11+
testString();
12+
function testString()
13+
{
14+
$token = "ABC";
15+
$lengthBytes = strlenb($token);
16+
var_dump($lengthBytes == 0);
17+
}
18+
19+
function strlenb() { return call_user_func_array("strlen", func_get_args()); }
20+
?>
21+
--EXPECT--
22+
bool(false)

0 commit comments

Comments
 (0)