From: Thomas Punt Date: Wed, 23 Mar 2016 23:57:50 +0000 (+0000) Subject: Fix DateInterval::format segfault X-Git-Tag: php-5.6.21RC1~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=40f14bad33f428994b4a590dafa8fe4d058f7241;p=php Fix DateInterval::format segfault --- diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 4cb0ec8ff4..4bb088881e 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -4359,6 +4359,10 @@ static char *date_interval_format(char *format, int format_len, timelib_rel_time smart_str_0(&string); + if (string.c == NULL) { + return estrdup(""); + } + return string.c; } /* }}} */ diff --git a/ext/date/tests/bug71889.phpt b/ext/date/tests/bug71889.phpt new file mode 100644 index 0000000000..129930a1fc --- /dev/null +++ b/ext/date/tests/bug71889.phpt @@ -0,0 +1,11 @@ +--TEST-- +Bug #71889 (DateInterval::format segfault on '%' input) +--INI-- +date.timezone=US/Eastern +--FILE-- +format("%")); +?> +--EXPECT-- +string(0) ""