com php-src: Fix DateInterval::format segfault: ext/date/php_ date.c ext/date/tests/bug71889.phpt
| From: | Anatol Belski | Date: | Tue, 05 Apr 2016 09:18:14 +0000 |
| Subject: | com php-src: Fix DateInterval::format segfault: ext/date/php_ date.c ext/date/tests/bug71889.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-91602@lists.php.net to get a copy of this message | ||
Commit: 40f14bad33f428994b4a590dafa8fe4d058f7241
Author: Thomas Punt <tpunt@hotmail.co.uk> Wed, 23 Mar 2016 23:57:50 +0000
Committer: Anatol Belski <ab@php.net> Tue, 5 Apr 2016 11:18:14 +0200
Parents: 30925cd49826c59ea8459a24bcb24d47c2ce562d
Branches: PHP-5.6 PHP-7.0 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=40f14bad33f428994b4a590dafa8fe4d058f7241
Log:
Fix DateInterval::format segfault
Changed paths:
M ext/date/php_date.c
A ext/date/tests/bug71889.phpt
Diff:
diff --git a/ext/date/php_date.c b/ext/date/php_date.c
index 4cb0ec8..4bb0888 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 0000000..129930a
--- /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) ""