Skip to content

Commit 40f14ba

Browse files
tpuntweltling
authored andcommitted
Fix DateInterval::format segfault
1 parent 30925cd commit 40f14ba

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

ext/date/php_date.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4359,6 +4359,10 @@ static char *date_interval_format(char *format, int format_len, timelib_rel_time
43594359

43604360
smart_str_0(&string);
43614361

4362+
if (string.c == NULL) {
4363+
return estrdup("");
4364+
}
4365+
43624366
return string.c;
43634367
}
43644368
/* }}} */

ext/date/tests/bug71889.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #71889 (DateInterval::format segfault on '%' input)
3+
--INI--
4+
date.timezone=US/Eastern
5+
--FILE--
6+
<?php
7+
$di = new DateInterval('P1D');
8+
var_dump($di->format("%"));
9+
?>
10+
--EXPECT--
11+
string(0) ""

0 commit comments

Comments
 (0)