Skip to content

Commit 353f963

Browse files
committed
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.
1 parent 36cb48c commit 353f963

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
strlen() null deprecation warning promoted to exception
3+
--FILE--
4+
<?php
5+
6+
set_error_handler(function($_, $msg) {
7+
throw new Exception($msg);
8+
});
9+
try {
10+
strlen(null);
11+
} catch (Exception $e) {
12+
echo $e->getMessage(), "\n";
13+
}
14+
15+
?>
16+
--EXPECT--
17+
strlen(): Passing null to parameter #1 ($string) of type string is deprecated

Zend/zend_vm_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8368,10 +8368,10 @@ ZEND_VM_COLD_CONST_HANDLER(121, ZEND_STRLEN, CONST|TMPVAR|CV, ANY)
83688368
if (UNEXPECTED(Z_TYPE_P(value) == IS_NULL)) {
83698369
zend_error(E_DEPRECATED,
83708370
"strlen(): Passing null to parameter #1 ($string) of type string is deprecated");
8371+
ZVAL_LONG(EX_VAR(opline->result.var), 0);
83718372
if (UNEXPECTED(EG(exception))) {
83728373
HANDLE_EXCEPTION();
83738374
}
8374-
ZVAL_LONG(EX_VAR(opline->result.var), 0);
83758375
break;
83768376
}
83778377

Zend/zend_vm_execute.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5461,10 +5461,10 @@ static ZEND_VM_COLD ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_STRLEN_SPEC_CONST
54615461
if (UNEXPECTED(Z_TYPE_P(value) == IS_NULL)) {
54625462
zend_error(E_DEPRECATED,
54635463
"strlen(): Passing null to parameter #1 ($string) of type string is deprecated");
5464+
ZVAL_LONG(EX_VAR(opline->result.var), 0);
54645465
if (UNEXPECTED(EG(exception))) {
54655466
HANDLE_EXCEPTION();
54665467
}
5467-
ZVAL_LONG(EX_VAR(opline->result.var), 0);
54685468
break;
54695469
}
54705470

@@ -14648,10 +14648,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_STRLEN_SPEC_TMPVAR_HANDLER(ZEN
1464814648
if (UNEXPECTED(Z_TYPE_P(value) == IS_NULL)) {
1464914649
zend_error(E_DEPRECATED,
1465014650
"strlen(): Passing null to parameter #1 ($string) of type string is deprecated");
14651+
ZVAL_LONG(EX_VAR(opline->result.var), 0);
1465114652
if (UNEXPECTED(EG(exception))) {
1465214653
HANDLE_EXCEPTION();
1465314654
}
14654-
ZVAL_LONG(EX_VAR(opline->result.var), 0);
1465514655
break;
1465614656
}
1465714657

@@ -38691,10 +38691,10 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_STRLEN_SPEC_CV_HANDLER(ZEND_OP
3869138691
if (UNEXPECTED(Z_TYPE_P(value) == IS_NULL)) {
3869238692
zend_error(E_DEPRECATED,
3869338693
"strlen(): Passing null to parameter #1 ($string) of type string is deprecated");
38694+
ZVAL_LONG(EX_VAR(opline->result.var), 0);
3869438695
if (UNEXPECTED(EG(exception))) {
3869538696
HANDLE_EXCEPTION();
3869638697
}
38697-
ZVAL_LONG(EX_VAR(opline->result.var), 0);
3869838698
break;
3869938699
}
3870038700

0 commit comments

Comments
 (0)