mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
Fix numfmt_parse_currency() reference handling
Closes GH-18472.
This commit is contained in:
@@ -135,7 +135,7 @@ PHP_FUNCTION( numfmt_parse_currency )
|
||||
FORMATTER_METHOD_INIT_VARS;
|
||||
|
||||
/* Parse parameters. */
|
||||
if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Osz/|z!",
|
||||
if( zend_parse_method_parameters( ZEND_NUM_ARGS(), getThis(), "Osz|z!",
|
||||
&object, NumberFormatter_ce_ptr, &str, &str_len, &zcurrency, &zposition ) == FAILURE )
|
||||
{
|
||||
RETURN_THROWS();
|
||||
@@ -165,8 +165,7 @@ PHP_FUNCTION( numfmt_parse_currency )
|
||||
/* Convert parsed currency to UTF-8 and pass it back to caller. */
|
||||
u8str = intl_convert_utf16_to_utf8(currency, u_strlen(currency), &INTL_DATA_ERROR_CODE(nfo));
|
||||
INTL_METHOD_CHECK_STATUS( nfo, "Currency conversion to UTF-8 failed" );
|
||||
zval_ptr_dtor( zcurrency );
|
||||
ZVAL_NEW_STR(zcurrency, u8str);
|
||||
ZEND_TRY_ASSIGN_REF_NEW_STR(zcurrency, u8str);
|
||||
|
||||
RETVAL_DOUBLE( number );
|
||||
}
|
||||
|
||||
20
ext/intl/tests/numfmt_parse_currency_references.phpt
Normal file
20
ext/intl/tests/numfmt_parse_currency_references.phpt
Normal file
@@ -0,0 +1,20 @@
|
||||
--TEST--
|
||||
numfmt_parse_currency() reference handling
|
||||
--EXTENSIONS--
|
||||
intl
|
||||
--FILE--
|
||||
<?php
|
||||
class Test {
|
||||
public int $prop = 1;
|
||||
}
|
||||
$test = new Test;
|
||||
$fmt = numfmt_create( 'de_DE', NumberFormatter::CURRENCY );
|
||||
$num = "1\xc2\xa0$";
|
||||
try {
|
||||
numfmt_parse_currency($fmt, $num, $test->prop);
|
||||
} catch (TypeError $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Cannot assign string to reference held by property Test::$prop of type int
|
||||
Reference in New Issue
Block a user