diff options
| -rw-r--r-- | ext/date/php_date.c | 4 | ||||
| -rw-r--r-- | ext/date/tests/bug71889.phpt | 11 |
2 files changed, 15 insertions, 0 deletions
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-- +<?php +$di = new DateInterval('P1D'); +var_dump($di->format("%")); +?> +--EXPECT-- +string(0) "" |
