Skip to content

Commit be28894

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: Fix GH-19397: mb_list_encodings() can cause crashes on shutdown
2 parents 99e6b0e + db3f6d0 commit be28894

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

ext/mbstring/mbstring.c

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

11621162
if (MBSTRG(all_encodings_list)) {
1163-
GC_DELREF(MBSTRG(all_encodings_list));
1164-
zend_array_destroy(MBSTRG(all_encodings_list));
1163+
/* must be *array* release to remove from GC root buffer and free the hashtable itself */
1164+
zend_array_release(MBSTRG(all_encodings_list));
11651165
MBSTRG(all_encodings_list) = NULL;
11661166
}
11671167

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)