Skip to content

Fix GH-12243, segfault on IntlDateFormatter::construct with dateType #12245

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

Conversation

devnexen
Copy link
Member

set to UDAT_PATTERN but not timeType.

udat_open expects its timeStyle's argument to be set to UDAT_PATTERN
when dateStyle is, regardless if there an actual pattern or not.

return FAILURE;
}
if (date_type == UDAT_PATTERN && time_type != UDAT_PATTERN) {
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: invalid time format style, UDAT_PATTERN expected", 0);
Copy link
Member

Choose a reason for hiding this comment

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

The error message is confusing here, I think something along the usual line of time format must be UDAT_PATTERN if date format is UDAT_PATTERN is clearer.

May or may not make sense to convert this to a ValueError in master

<?php

$datetime = new \DateTime('2017-05-12 23:11:00 GMT+2');
static $UDAT_PATTERN = -2;
Copy link
Member

Choose a reason for hiding this comment

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

Feels like this constant should also be defined in the future?

Copy link
Member Author

Choose a reason for hiding this comment

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

agreed

 set to UDAT_PATTERN but not timeType.

udat_open expects its timeStyle's argument to be set to UDAT_PATTERN
 when dateStyle is, regardless if there an actual pattern or not.
@devnexen devnexen force-pushed the fix_intl_date_formatter_sigsegv branch from 866d20f to 2f9d3f9 Compare September 20, 2023 17:08
@devnexen devnexen closed this in 84c4336 Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IntlDateFormatter crashes (SIGSEGV) when dateType is outside expected range
2 participants