1
0
mirror of https://github.com/php/php-src.git synced 2026-04-26 17:38:14 +02:00
Files
Alex Dowad e934c5cde1 New test case from ed0c0df351 exercises the code it was intended to
In ed0c0df351, 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.
2023-02-22 23:06:47 +02:00

37 lines
840 B
PHP

--TEST--
GH-10627 (mb_convert_encoding crashes PHP on Windows)
--EXTENSIONS--
mbstring
--INI--
mbstring.strict_detection=1
--FILE--
<?php
$str = "S\xF6kinst\xE4llningar";
$data = [$str, 'abc'];
var_dump(mb_convert_encoding($data, 'UTF-8', 'auto'));
$data = [$str => 'abc', 'abc' => 'def'];
var_dump(mb_convert_encoding($data, 'UTF-8', 'auto'));
$data = ['abc' => $str, 'def' => 'abc'];
var_dump(mb_convert_encoding($data, 'UTF-8', 'auto'));
?>
--EXPECTF--
Warning: mb_convert_encoding(): Unable to detect character encoding in %s on line %d
array(1) {
[1]=>
string(3) "abc"
}
Warning: mb_convert_encoding(): Unable to detect character encoding in %s on line %d
array(1) {
["abc"]=>
string(3) "def"
}
Warning: mb_convert_encoding(): Unable to detect character encoding in %s on line %d
array(1) {
["def"]=>
string(3) "abc"
}