Skip to content

Fix DateInterval::format segfault (bug #71889) - #1837

Closed
tpunt wants to merge 2 commits into
php:PHP-5.6from
tpunt:fix-dateinterval-segfault
Closed

tpunt wants to merge 2 commits into
php:PHP-5.6from
tpunt:fix-dateinterval-segfault

Conversation

@tpunt

@tpunt tpunt commented Mar 23, 2016

Copy link
Copy Markdown
Contributor

Fixes a segfault when using DateInterval::format('%'). This affects PHP 7 and master too.

/cc @derickr

@tpunt
tpunt force-pushed the fix-dateinterval-segfault branch from 4b5ffb8 to 872a368 Compare March 23, 2016 23:56
@tpunt
tpunt force-pushed the fix-dateinterval-segfault branch from 872a368 to 6be549e Compare March 23, 2016 23:57
Comment thread ext/date/php_date.c Outdated
smart_str_0(&string);

if (string.c == NULL) {
return estrdup("");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use:

return STR_EMPTY_ALLOC();

for PHP7 use:

return ZSTR_EMPTY_ALLOC();

@derickr

derickr commented Mar 24, 2016

Copy link
Copy Markdown
Member

LGTM, after you:

  • fixed the things that @laruence pointed out

@tpunt

tpunt commented Mar 24, 2016

Copy link
Copy Markdown
Contributor Author

Thanks for the reviews. I've rectified the patch and Travis passes now.

@php-pulls

Copy link
Copy Markdown

Comment on behalf of ab at php.net:

Merged in 5.6+ with 40f14ba and 1aea777.

Thanks.

@php-pulls php-pulls closed this Apr 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants