mirror of
https://github.com/php/php-src.git
synced 2024-09-21 09:57:23 +00:00
Fix GH-12243, segfault on IntlDateFormatter::construct with dateType 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. Close GH-12245
This commit is contained in:
parent
da6097ffc8
commit
84c4336aa3
5
NEWS
5
NEWS
@ -15,6 +15,11 @@ PHP NEWS
|
||||
. Fixed bug GH-12186 (segfault copying/cloning a finalized HashContext).
|
||||
(MaxSem)
|
||||
|
||||
- Intl:
|
||||
. Fixed bug GH-12243 (segfault on IntlDateFormatter::construct).
|
||||
(David Carlier)
|
||||
|
||||
|
||||
- PCRE:
|
||||
. Fixed bug GH-11956 (Backport upstream fix, PCRE regular expressions with
|
||||
JIT enabled gives different result). (nielsdos)
|
||||
|
@ -99,7 +99,11 @@ static zend_result datefmt_ctor(INTERNAL_FUNCTION_PARAMETERS, zend_error_handlin
|
||||
}
|
||||
if (!INTL_UDATE_FMT_OK(time_type)) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: invalid time format style", 0);
|
||||
return FAILURE;
|
||||
return FAILURE;
|
||||
}
|
||||
if (date_type == UDAT_PATTERN && time_type != UDAT_PATTERN) {
|
||||
intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR, "datefmt_create: time format must be UDAT_PATTERN if date format is UDAT_PATTERN", 0);
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
INTL_CHECK_LOCALE_LEN_OR_FAILURE(locale_len);
|
||||
|
24
ext/intl/tests/gh12243.phpt
Normal file
24
ext/intl/tests/gh12243.phpt
Normal file
@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
GitHub #12043 segfault with IntlDateFormatter::dateType where it equals to UDAT_PATTERN (icu 50) but
|
||||
IntldateFormatter::timeType needs to be set as such.
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$datetime = new \DateTime('2017-05-12 23:11:00 GMT+2');
|
||||
static $UDAT_PATTERN = -2;
|
||||
|
||||
try {
|
||||
new IntlDateFormatter(
|
||||
locale: 'en',
|
||||
dateType: $UDAT_PATTERN,
|
||||
timeType: 0,
|
||||
timezone: $datetime->getTimezone(),
|
||||
);
|
||||
} catch (\IntlException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
--EXPECT--
|
||||
datefmt_create: time format must be UDAT_PATTERN if date format is UDAT_PATTERN: U_ILLEGAL_ARGUMENT_ERROR
|
Loading…
Reference in New Issue
Block a user