com php-src: Fixed bug #76477 (Opcache causes empty return value): NEWS ext/opcache/Optimizer/zend_call_graph.c ext/opcache/Opt
imizer/zend_func_info.c ext/opcache/tests/bug764 77.phpt

From: Date: Fri, 15 Jun 2018 08:31:31 +0000
Subject: com php-src: Fixed bug #76477 (Opcache causes empty return value): NEWS ext/opcache/Optimizer/zend_call_graph.c ext/opcache/Opt
imizer/zend_func_info.c ext/opcache/tests/bug764 77.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-102159@lists.php.net to get a copy of this message
Commit: f31ba7cb53271f6745c5efb1b15c53ffd5cb4b6e Author: Xinchen Hui <laruence@gmail.com> Fri, 15 Jun 2018 16:31:31 +0800 Parents: dad8bd585104fd8b67e54a85a4af134b5261f351 Branches: PHP-7.2 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f31ba7cb53271f6745c5efb1b15c53ffd5cb4b6e Log: Fixed bug #76477 (Opcache causes empty return value) Bugs: https://bugs.php.net/76477 Changed paths: M NEWS M ext/opcache/Optimizer/zend_call_graph.c M ext/opcache/Optimizer/zend_func_info.c A ext/opcache/tests/bug76477.phpt Diff: diff --git a/NEWS b/NEWS index 3c9ae59..2412ad4 100644 --- a/NEWS +++ b/NEWS @@ -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 886a793..a0ea479 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 19b8e51..b32a954 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 0000000..39bff0d --- /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)

« previous php.cvs (#102159) next »