Fixed bug #76477 (Opcache causes empty return value)

This commit is contained in:
Xinchen Hui 2018-06-15 16:31:31 +08:00
parent dad8bd5851
commit f31ba7cb53
4 changed files with 36 additions and 5 deletions

4
NEWS
View File

@ -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)

View File

@ -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++;

View File

@ -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;
}
}

View File

@ -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)