1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

datefmt_parse/datefmt_localtime references type system fixes

Closes GH-18441.
This commit is contained in:
Niels Dossche
2025-04-27 00:29:12 +02:00
parent 2eb3100dca
commit 2beec54e47
3 changed files with 46 additions and 10 deletions

3
NEWS
View File

@@ -7,6 +7,9 @@ PHP NEWS
inaccurate sunrise and sunset times, but other calculated times are
correct) (JiriJozif).
- Intl:
. datefmt_parse/datefmt_localtime references type system fixes. (nielsdos)
- SPL:
. Fixed bug GH-18421 (Integer overflow with large numbers in LimitIterator).
(nielsdos)

View File

@@ -136,9 +136,9 @@ PHP_FUNCTION(datefmt_parse)
DATE_FORMAT_METHOD_FETCH_OBJECT;
if (z_parse_pos) {
zend_long long_parse_pos;
ZVAL_DEREF(z_parse_pos);
long_parse_pos = zval_get_long(z_parse_pos);
zval *z_parse_pos_tmp = z_parse_pos;
ZVAL_DEREF(z_parse_pos_tmp);
zend_long long_parse_pos = zval_get_long(z_parse_pos_tmp);
if (ZEND_LONG_INT_OVFL(long_parse_pos)) {
intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR);
intl_error_set_custom_msg(NULL, "String index is out of valid range.", 0);
@@ -151,8 +151,7 @@ PHP_FUNCTION(datefmt_parse)
}
internal_parse_to_timestamp( dfo, text_to_parse, text_len, z_parse_pos?&parse_pos:NULL, return_value);
if(z_parse_pos) {
zval_ptr_dtor(z_parse_pos);
ZVAL_LONG(z_parse_pos, parse_pos);
ZEND_TRY_ASSIGN_REF_LONG(z_parse_pos, parse_pos);
}
}
/* }}} */
@@ -177,9 +176,9 @@ PHP_FUNCTION(datefmt_localtime)
DATE_FORMAT_METHOD_FETCH_OBJECT;
if (z_parse_pos) {
zend_long long_parse_pos;
ZVAL_DEREF(z_parse_pos);
long_parse_pos = zval_get_long(z_parse_pos);
zval *z_parse_pos_tmp = z_parse_pos;
ZVAL_DEREF(z_parse_pos_tmp);
zend_long long_parse_pos = zval_get_long(z_parse_pos_tmp);
if (ZEND_LONG_INT_OVFL(long_parse_pos)) {
intl_error_set_code(NULL, U_ILLEGAL_ARGUMENT_ERROR);
intl_error_set_custom_msg(NULL, "String index is out of valid range.", 0);
@@ -192,8 +191,7 @@ PHP_FUNCTION(datefmt_localtime)
}
internal_parse_to_localtime( dfo, text_to_parse, text_len, z_parse_pos?&parse_pos:NULL, return_value);
if (z_parse_pos) {
zval_ptr_dtor(z_parse_pos);
ZVAL_LONG(z_parse_pos, parse_pos);
ZEND_TRY_ASSIGN_REF_LONG(z_parse_pos, parse_pos);
}
}
/* }}} */

View File

@@ -0,0 +1,35 @@
--TEST--
datefmt_parse/datefmt_localtime references type system
--EXTENSIONS--
intl
--FILE--
<?php
class Test {
public float $prop = 1.0;
}
$test = new Test;
$offset1 =& $test->prop;
$offset2 =& $test->prop;
$fmt = datefmt_create(
'en_US',
IntlDateFormatter::FULL,
IntlDateFormatter::FULL,
'America/Los_Angeles',
IntlDateFormatter::GREGORIAN
);
datefmt_localtime($fmt, 'Wednesday, December 31, 1969 4:00:00 PM PT', $offset1);
datefmt_parse($fmt, 'Wednesday, December 31, 1969 4:00:00 PM PT', $offset2);
var_dump($offset1, $offset2);
var_dump($test);
?>
--EXPECT--
float(1)
float(1)
object(Test)#1 (1) {
["prop"]=>
&float(1)
}