From 9b7c807f39d565a2102c08e09e51b402c2cbad50 Mon Sep 17 00:00:00 2001 From: Alex Dowad Date: Wed, 22 Feb 2023 19:09:39 +0200 Subject: [PATCH] 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. --- ext/mbstring/tests/gh10627.phpt | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/ext/mbstring/tests/gh10627.phpt b/ext/mbstring/tests/gh10627.phpt index 901027a38212..2f4af8c559e1 100644 --- a/ext/mbstring/tests/gh10627.phpt +++ b/ext/mbstring/tests/gh10627.phpt @@ -2,27 +2,35 @@ GH-10627 (mb_convert_encoding crashes PHP on Windows) --EXTENSIONS-- mbstring +--INI-- +mbstring.strict_detection=1 --FILE-- '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')); ?> ---EXPECT-- -array(2) { - [0]=> - string(16) "S?kinst?llningar" +--EXPECTF-- +Warning: mb_convert_encoding(): Unable to detect character encoding in %s on line %d +array(1) { [1]=> string(3) "abc" } -array(2) { - ["S?kinst?llningar"]=> - 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" +}