Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ext/mbstring/mbstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -1165,8 +1165,10 @@ PHP_RSHUTDOWN_FUNCTION(mbstring)
MBSTRG(outconv_state) = 0;

if (MBSTRG(all_encodings_list)) {
GC_DELREF(MBSTRG(all_encodings_list));
zend_array_destroy(MBSTRG(all_encodings_list));
if (GC_DELREF(MBSTRG(all_encodings_list)) == 0) {
/* must be *array* destroy to remove from GC root buffer and free the hashtable itself */
zend_array_destroy(MBSTRG(all_encodings_list));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use zend_array_release?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wanted to avoid the immutability check, but sure

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact that's what I proposed initially #19397 (comment)

MBSTRG(all_encodings_list) = NULL;
}

Expand Down
11 changes: 11 additions & 0 deletions ext/mbstring/tests/gh19397.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
GH-19397 (mb_list_encodings() can cause crashes on shutdown)
--EXTENSIONS--
mbstring
--FILE--
<?php
$doNotDeleteThisVariableAssignment = mb_list_encodings();
var_dump(count($doNotDeleteThisVariableAssignment) > 0);
?>
--EXPECT--
bool(true)
Loading