summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Punt <tpunt@hotmail.co.uk>2016-03-23 23:57:50 +0000
committerAnatol Belski <ab@php.net>2016-04-05 11:18:14 +0200
commit40f14bad33f428994b4a590dafa8fe4d058f7241 (patch)
treefbe8df97e7bf4ba1d0bac85bbe36d4007410c6e1
parent30925cd49826c59ea8459a24bcb24d47c2ce562d (diff)
downloadphp-git-40f14bad33f428994b4a590dafa8fe4d058f7241.tar.gz
Fix DateInterval::format segfault
-rw-r--r--ext/date/php_date.c4
-rw-r--r--ext/date/tests/bug71889.phpt11
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) ""