Skip to content

Commit 646f1a0

Browse files
committed
Merge branch 'PHP-8.6'
* PHP-8.6: ext/intl: intl_error_set_custom_msg() crash without an active call frame
2 parents cc9282a + febda02 commit 646f1a0

2 files changed

Lines changed: 33 additions & 7 deletions

File tree

‎ext/intl/intl_error.c‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,18 @@ void intl_error_set_custom_msg( intl_error* err, const char* msg)
9191
return;
9292
}
9393

94-
zend_string *method_or_func = get_active_function_or_method_name();
95-
zend_string *prefixed_message = zend_string_concat3(
96-
ZSTR_VAL(method_or_func), ZSTR_LEN(method_or_func),
97-
ZEND_STRL("(): "),
98-
msg, strlen(msg)
99-
);
100-
zend_string_release_ex(method_or_func, false);
94+
zend_string *prefixed_message;
95+
if (zend_is_executing()) {
96+
zend_string *method_or_func = get_active_function_or_method_name();
97+
prefixed_message = zend_string_concat3(
98+
ZSTR_VAL(method_or_func), ZSTR_LEN(method_or_func),
99+
ZEND_STRL("(): "),
100+
msg, strlen(msg)
101+
);
102+
zend_string_release_ex(method_or_func, false);
103+
} else {
104+
prefixed_message = zend_string_init(msg, strlen(msg), false);
105+
}
101106

102107
if( !err ) {
103108
if (INTL_G(error_level)) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
UConverter subclass destroyed at request shutdown does not crash
3+
--EXTENSIONS--
4+
intl
5+
--FILE--
6+
<?php
7+
class MyConverter extends UConverter {
8+
public function toUCallback($reason, $source, $codeUnits, &$error): string|int|array|null {
9+
return '?';
10+
}
11+
12+
public function fromUCallback($reason, $source, $codePoint, &$error): string|int|array|null {
13+
return '?';
14+
}
15+
}
16+
17+
$converter = new MyConverter('ascii', 'utf-8');
18+
echo 'end of script', PHP_EOL;
19+
?>
20+
--EXPECT--
21+
end of script

0 commit comments

Comments
 (0)