Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion ext/mbstring/mbstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,9 @@ PHP_FUNCTION(mb_output_handler)
char *mimetype = NULL;

/* Analyze mime type */
if (SG(sapi_headers).mimetype && _php_mb_match_regex(MBSTRG(http_output_conv_mimetypes), SG(sapi_headers).mimetype, strlen(SG(sapi_headers).mimetype))) {
if (SG(sapi_headers).mimetype
&& MBSTRG(http_output_conv_mimetypes)
&& _php_mb_match_regex(MBSTRG(http_output_conv_mimetypes), SG(sapi_headers).mimetype, strlen(SG(sapi_headers).mimetype))) {
char *s;
if ((s = strchr(SG(sapi_headers).mimetype, ';')) == NULL) {
mimetype = estrdup(SG(sapi_headers).mimetype);
Expand Down
16 changes: 16 additions & 0 deletions ext/mbstring/tests/gh17989.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
GH-17989 (mb_output_handler crash with unset http_output_conv_mimetypes)
--EXTENSIONS--
mbstring
--INI--
mbstring.http_output_conv_mimetypes=
--FILE--
<?php
echo "set mime type via this echo\n";
ob_start('mb_output_handler');
echo "hi";
ob_flush();
?>
--EXPECT--
set mime type via this echo
hi
Loading