Skip to content

Commit 47a0922

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-17503: Undefined float conversion in mb_convert_variables
2 parents d3101fb + 55e676e commit 47a0922

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ PHP NEWS
1616
. Fixed bug GH-17609 (Typo in error message: Dom\NO_DEFAULT_NS instead of
1717
Dom\HTML_NO_DEFAULT_NS). (nielsdos)
1818

19+
- MBString:
20+
. Fixed bug GH-17503 (Undefined float conversion in mb_convert_variables).
21+
(cmb)
22+
1923
- Opcache:
2024
. Fixed bug GH-17654 (Multiple classes using same trait causes function
2125
JIT crash). (nielsdos)

ext/mbstring/mbstring.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -3348,7 +3348,8 @@ try_next_encoding:;
33483348
}
33493349

33503350
for (size_t i = 0; i < length; i++) {
3351-
array[i].demerits *= array[i].multiplier;
3351+
double demerits = array[i].demerits * (double) array[i].multiplier;
3352+
array[i].demerits = demerits < (double) UINT64_MAX ? (uint64_t) demerits : UINT64_MAX;
33523353
}
33533354

33543355
return length;

ext/mbstring/tests/gh17503.phpt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
GH-17503 (Undefined float conversion in mb_convert_variables)
3+
--EXTENSIONS--
4+
mbstring
5+
--FILE--
6+
<?php
7+
$a = array_fill(0, 500, "<blah>");
8+
var_dump(mb_convert_variables("ASCII", ["UTF-8", "UTF-16"], $a));
9+
?>
10+
--EXPECT--
11+
string(5) "UTF-8"

0 commit comments

Comments
 (0)