diff --git a/ext/intl/formatter/formatter_parse.c b/ext/intl/formatter/formatter_parse.c index 8ea066c586c1f..c31ece7dd9870 100644 --- a/ext/intl/formatter/formatter_parse.c +++ b/ext/intl/formatter/formatter_parse.c @@ -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 ); } diff --git a/ext/intl/tests/numfmt_parse_currency_references.phpt b/ext/intl/tests/numfmt_parse_currency_references.phpt new file mode 100644 index 0000000000000..06427a736930b --- /dev/null +++ b/ext/intl/tests/numfmt_parse_currency_references.phpt @@ -0,0 +1,20 @@ +--TEST-- +numfmt_parse_currency() reference handling +--EXTENSIONS-- +intl +--FILE-- +prop); +} catch (TypeError $e) { + echo $e->getMessage(), "\n"; +} +?> +--EXPECT-- +Cannot assign string to reference held by property Test::$prop of type int