Init STRLEN result when deprecation promoted to exception

Move the result initialization before HANDLE_EXCEPTION(), the
actual value doesn't matter.

This fixes one of the issues report in bug #81190.
This commit is contained in:
Nikita Popov 2021-07-01 16:21:24 +02:00
parent 36cb48c937
commit 353f963bba
3 changed files with 21 additions and 4 deletions

View File

@ -0,0 +1,17 @@
--TEST--
strlen() null deprecation warning promoted to exception
--FILE--
<?php
set_error_handler(function($_, $msg) {
throw new Exception($msg);
});
try {
strlen(null);
} catch (Exception $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
strlen(): Passing null to parameter #1 ($string) of type string is deprecated

View File

@ -8368,10 +8368,10 @@ ZEND_VM_COLD_CONST_HANDLER(121, ZEND_STRLEN, CONST|TMPVAR|CV, ANY)
if (UNEXPECTED(Z_TYPE_P(value) == IS_NULL)) {
zend_error(E_DEPRECATED,
"strlen(): Passing null to parameter #1 ($string) of type string is deprecated");
ZVAL_LONG(EX_VAR(opline->result.var), 0);
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
ZVAL_LONG(EX_VAR(opline->result.var), 0);
break;
}

View File

@ -5461,10 +5461,10 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_STRLEN_SPEC_CONST
if (UNEXPECTED(Z_TYPE_P(value) == IS_NULL)) {
zend_error(E_DEPRECATED,
"strlen(): Passing null to parameter #1 ($string) of type string is deprecated");
ZVAL_LONG(EX_VAR(opline->result.var), 0);
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
ZVAL_LONG(EX_VAR(opline->result.var), 0);
break;
}
@ -14648,10 +14648,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_STRLEN_SPEC_TMPVAR_HANDLER(ZEN
if (UNEXPECTED(Z_TYPE_P(value) == IS_NULL)) {
zend_error(E_DEPRECATED,
"strlen(): Passing null to parameter #1 ($string) of type string is deprecated");
ZVAL_LONG(EX_VAR(opline->result.var), 0);
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
ZVAL_LONG(EX_VAR(opline->result.var), 0);
break;
}
@ -38691,10 +38691,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_STRLEN_SPEC_CV_HANDLER(ZEND_OP
if (UNEXPECTED(Z_TYPE_P(value) == IS_NULL)) {
zend_error(E_DEPRECATED,
"strlen(): Passing null to parameter #1 ($string) of type string is deprecated");
ZVAL_LONG(EX_VAR(opline->result.var), 0);
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
ZVAL_LONG(EX_VAR(opline->result.var), 0);
break;
}