Skip to content

Commit e934c5c

Browse files
committed
New test case from ed0c0df exercises the code it was intended to
In ed0c0df, Niels Dossche fixed a bug in mbstring whereby mb_convert_encoding could dereference a NULL pointer and crash if it was called on an array, with multiple candidate encodings, and at least one of the strings inside the array was invalid in all the candidate encodings. He kindly included a test case, but after being merged into master, the test case was not actually testing what it was intended to test. That is now fixed.
1 parent 343191a commit e934c5c

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

ext/mbstring/tests/gh10627.phpt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,35 @@
22
GH-10627 (mb_convert_encoding crashes PHP on Windows)
33
--EXTENSIONS--
44
mbstring
5+
--INI--
6+
mbstring.strict_detection=1
57
--FILE--
68
<?php
79

8-
$str = 'Sökinställningar';
10+
$str = "S\xF6kinst\xE4llningar";
911
$data = [$str, 'abc'];
1012
var_dump(mb_convert_encoding($data, 'UTF-8', 'auto'));
1113
$data = [$str => 'abc', 'abc' => 'def'];
1214
var_dump(mb_convert_encoding($data, 'UTF-8', 'auto'));
15+
$data = ['abc' => $str, 'def' => 'abc'];
16+
var_dump(mb_convert_encoding($data, 'UTF-8', 'auto'));
1317

1418
?>
15-
--EXPECT--
16-
array(2) {
17-
[0]=>
18-
string(16) "S?kinst?llningar"
19+
--EXPECTF--
20+
Warning: mb_convert_encoding(): Unable to detect character encoding in %s on line %d
21+
array(1) {
1922
[1]=>
2023
string(3) "abc"
2124
}
22-
array(2) {
23-
["S?kinst?llningar"]=>
24-
string(3) "abc"
25+
26+
Warning: mb_convert_encoding(): Unable to detect character encoding in %s on line %d
27+
array(1) {
2528
["abc"]=>
2629
string(3) "def"
2730
}
2831

32+
Warning: mb_convert_encoding(): Unable to detect character encoding in %s on line %d
33+
array(1) {
34+
["def"]=>
35+
string(3) "abc"
36+
}

0 commit comments

Comments
 (0)