Skip to content

ext/mbstring: Add missing reference to INI value in mb_get_info() - #25596

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/mbstring-get-info-refs
Open

iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/mbstring-get-info-refs

Conversation

@iliaal

@iliaal iliaal commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

After ini_set() stores a runtime value for mbstring.http_output_conv_mimetypes, mb_get_info() returns that string, alone or in the "all" array, without adding a reference, so destroying the result frees the string and a later ini_get() reads freed memory. Add the reference and drop the @refcount 1 annotation, since the result can now be shared with the INI entry. Backport of the refcount part of b621f80 by Gina

mb_get_info() returned the mbstring.http_output_conv_mimetypes INI string,
for the "http_output_conv_mimetypes" type and in the "all" array, without
adding a reference. After ini_set() stores a non-interned value, each call
drops one of the INI entry's references, so the string is freed while the
entry still points to it and a later ini_get() reads freed memory. With the
reference added the returned string can be shared, so drop the @refcount 1
annotation that lets the function JIT destroy a discarded result without
checking its refcount.

Backport of the refcount part of b621f80 by Gina Peter Banyard.
@iliaal

iliaal commented Nov 19, 2026

Copy link
Copy Markdown
Member Author

@Girgias Was there a reason why it didn't go into 8.4, if there is a good reason perhaps this PR is not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant