Skip to content

datefmt_parse/datefmt_localtime references type system fixes #18441

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 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions ext/intl/dateformat/dateformat_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
/* }}} */
Expand All @@ -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);
Expand All @@ -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);
}
}
/* }}} */
35 changes: 35 additions & 0 deletions ext/intl/tests/datefmt_parse_localtime_references.phpt
Original file line number Diff line number Diff line change
@@ -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)
}
Loading