Skip to content

Commit db3f6d0

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix GH-19397: mb_list_encodings() can cause crashes on shutdown
2 parents 11e6655 + cc93bbb commit db3f6d0

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ PHP NEWS
4949
. Fixed bug GH-19098 (libxml<2.13 segmentation fault caused by
5050
php_libxml_node_free). (nielsdos)
5151

52+
- MbString:
53+
. Fixed bug GH-19397 (mb_list_encodings() can cause crashes on shutdown).
54+
(nielsdos)
55+
5256
- Opcache:
5357
. Reset global pointers to prevent use-after-free in zend_jit_status().
5458
(Florian Engelhardt)

ext/mbstring/mbstring.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,8 +1166,8 @@ PHP_RSHUTDOWN_FUNCTION(mbstring)
11661166
MBSTRG(outconv_state) = 0;
11671167

11681168
if (MBSTRG(all_encodings_list)) {
1169-
GC_DELREF(MBSTRG(all_encodings_list));
1170-
zend_array_destroy(MBSTRG(all_encodings_list));
1169+
/* must be *array* release to remove from GC root buffer and free the hashtable itself */
1170+
zend_array_release(MBSTRG(all_encodings_list));
11711171
MBSTRG(all_encodings_list) = NULL;
11721172
}
11731173

ext/mbstring/tests/gh19397.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
GH-19397 (mb_list_encodings() can cause crashes on shutdown)
3+
--EXTENSIONS--
4+
mbstring
5+
--FILE--
6+
<?php
7+
$doNotDeleteThisVariableAssignment = mb_list_encodings();
8+
var_dump(count($doNotDeleteThisVariableAssignment) > 0);
9+
?>
10+
--EXPECT--
11+
bool(true)

0 commit comments

Comments
 (0)