diff options
| -rw-r--r-- | NEWS | 4 | ||||
| -rw-r--r-- | ext/opcache/Optimizer/zend_call_graph.c | 5 | ||||
| -rw-r--r-- | ext/opcache/Optimizer/zend_func_info.c | 10 | ||||
| -rw-r--r-- | ext/opcache/tests/bug76477.phpt | 22 |
4 files changed, 36 insertions, 5 deletions
@@ -8,6 +8,10 @@ PHP NEWS - EXIF: . Fixed bug #76409 (heap use after free in _php_stream_free). (cmb) +- Opcache: + . Fixed bug #76477 (Opcache causes empty return value). + (Nikita, Laruence) + - ZIP: . Fixed bug #76461 (OPSYS_Z_CPM defined instead of OPSYS_CPM). (Dennis Birkholz, Remi) diff --git a/ext/opcache/Optimizer/zend_call_graph.c b/ext/opcache/Optimizer/zend_call_graph.c index 886a793971..a0ea479ef8 100644 --- a/ext/opcache/Optimizer/zend_call_graph.c +++ b/ext/opcache/Optimizer/zend_call_graph.c @@ -155,6 +155,7 @@ int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_f case ZEND_SEND_REF: case ZEND_SEND_VAR_NO_REF: case ZEND_SEND_VAR_NO_REF_EX: + case ZEND_SEND_USER: if (call_info) { uint32_t num = opline->op2.num; @@ -165,9 +166,11 @@ int zend_analyze_calls(zend_arena **arena, zend_script *script, uint32_t build_f } break; case ZEND_SEND_ARRAY: - case ZEND_SEND_USER: case ZEND_SEND_UNPACK: /* TODO: set info about var_arg call ??? */ + if (call_info) { + call_info->num_args = -1; + } break; } opline++; diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c index 19b8e51730..b32a954c1f 100644 --- a/ext/opcache/Optimizer/zend_func_info.c +++ b/ext/opcache/Optimizer/zend_func_info.c @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id:$ */ - #include "php.h" #include "zend_compile.h" #include "zend_extensions.h" @@ -79,9 +77,11 @@ static uint32_t zend_strlen_info(const zend_call_info *call_info, const zend_ssa tmp |= MAY_BE_LONG | FUNC_MAY_WARN | MAY_BE_NULL; } return tmp; - } else { + } else if (call_info->num_args != -1) { /* warning, and returns NULL */ return FUNC_MAY_WARN | MAY_BE_NULL; + } else { + return MAY_BE_LONG | FUNC_MAY_WARN | MAY_BE_NULL; } } @@ -90,9 +90,11 @@ static uint32_t zend_dechex_info(const zend_call_info *call_info, const zend_ssa if (call_info->caller_init_opline->extended_value == (uint32_t)call_info->num_args && call_info->num_args == 1) { return MAY_BE_RC1 | MAY_BE_STRING; - } else { + } else if (call_info->num_args != -1) { /* warning, and returns NULL */ return FUNC_MAY_WARN | MAY_BE_NULL; + } else { + return FUNC_MAY_WARN | MAY_BE_RC1 | MAY_BE_STRING | MAY_BE_NULL; } } diff --git a/ext/opcache/tests/bug76477.phpt b/ext/opcache/tests/bug76477.phpt new file mode 100644 index 0000000000..39bff0d46c --- /dev/null +++ b/ext/opcache/tests/bug76477.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #76477 (Opcache causes empty return value) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.optimization_level=-1 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +testString(); +function testString() +{ + $token = "ABC"; + $lengthBytes = strlenb($token); + var_dump($lengthBytes == 0); +} + +function strlenb() { return call_user_func_array("strlen", func_get_args()); } +?> +--EXPECT-- +bool(false) |
