From 40f14bad33f428994b4a590dafa8fe4d058f7241 Mon Sep 17 00:00:00 2001 From: Thomas Punt Date: Wed, 23 Mar 2016 23:57:50 +0000 Subject: [PATCH] Fix DateInterval::format segfault --- ext/date/php_date.c | 4 ++++ ext/date/tests/bug71889.phpt | 11 +++++++++++ 2 files changed, 15 insertions(+) create mode 100644 ext/date/tests/bug71889.phpt 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) "" -- 2.40.0