Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

tpunt
Copy link
Contributor

@tpunt tpunt commented Mar 23, 2016

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
@@ -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("");
Copy link
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
Copy link
Member

derickr commented Mar 24, 2016

LGTM, after you:

  • fixed the things that @laruence pointed out

@tpunt
Copy link
Contributor Author

tpunt commented Mar 24, 2016

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

@php-pulls
Copy link

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