Skip to content

IntlDateFormatter crashes (SIGSEGV) when dateType is outside expected range #12243

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
mrblur opened this issue Sep 19, 2023 · 1 comment
Closed

Comments

@mrblur
Copy link

mrblur commented Sep 19, 2023

Description

The following code:

<?php

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

$formatter = new IntlDateFormatter(
	locale: 'en',
	dateType: -2,
	timeType: 0,
	timezone: $datetime->getTimezone(),
);

var_dump($formatter->format($datetime));

Resulted in this output:

SIGSEGV

But I expected this output instead:

false

PHP Version

PHP 8.1.22

Operating System

No response

@mrblur mrblur changed the title IntlDateFormatter crashes (SIGSEGV) when dateType is outside recognized range IntlDateFormatter crashes (SIGSEGV) when dateType is outside expected range Sep 19, 2023
@devnexen
Copy link
Member

devnexen commented Sep 19, 2023

Seems to me that since UDAT_PATTERN is passed (-2) for dateType, timeType needs to be too, but I ll have a better look later.

@devnexen devnexen self-assigned this Sep 19, 2023
devnexen added a commit to devnexen/php-src that referenced this issue Sep 19, 2023
 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 added a commit to devnexen/php-src that referenced this issue Sep 19, 2023
 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 added a commit to devnexen/php-src that referenced this issue Sep 20, 2023
 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants