diff --git a/ext/intl/formatter/formatter_parse.c b/ext/intl/formatter/formatter_parse.c index de3b8191e9e..99399006504 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/grapheme/grapheme_string.c b/ext/intl/grapheme/grapheme_string.c index bfc352bdca2..9bc7796cc35 100644 --- a/ext/intl/grapheme/grapheme_string.c +++ b/ext/intl/grapheme/grapheme_string.c @@ -734,15 +734,10 @@ PHP_FUNCTION(grapheme_extract) } if ( NULL != next ) { - if ( !Z_ISREF_P(next) ) { - intl_error_set( NULL, U_ILLEGAL_ARGUMENT_ERROR, - "grapheme_extract: 'next' was not passed by reference", 0 ); - RETURN_FALSE; - } else { - ZVAL_DEREF(next); - /* initialize next */ - zval_ptr_dtor(next); - ZVAL_LONG(next, lstart); + ZEND_ASSERT(Z_ISREF_P(next)); + ZEND_TRY_ASSIGN_REF_LONG(next, lstart); + if (UNEXPECTED(EG(exception))) { + RETURN_THROWS(); } } @@ -800,7 +795,7 @@ PHP_FUNCTION(grapheme_extract) if ( -1 != grapheme_ascii_check((unsigned char *)pstr, MIN(size + 1, str_len)) ) { size_t nsize = MIN(size, str_len); if ( NULL != next ) { - ZVAL_LONG(next, start+nsize); + ZEND_TRY_ASSIGN_REF_LONG(next, start + nsize); } RETURN_STRINGL(pstr, nsize); } @@ -834,7 +829,7 @@ PHP_FUNCTION(grapheme_extract) ubrk_close(bi); if ( NULL != next ) { - ZVAL_LONG(next, start+ret_pos); + ZEND_TRY_ASSIGN_REF_LONG(next, start + ret_pos); } RETURN_STRINGL(((char *)pstr), ret_pos); diff --git a/ext/intl/tests/grapheme_extract_references.phpt b/ext/intl/tests/grapheme_extract_references.phpt new file mode 100644 index 00000000000..33368279a1a --- /dev/null +++ b/ext/intl/tests/grapheme_extract_references.phpt @@ -0,0 +1,19 @@ +--TEST-- +grapheme_extract() references handling +--EXTENSIONS-- +intl +--FILE-- +prop; +grapheme_extract("test", 4, next: $next); +var_dump($test); +?> +--EXPECT-- +object(Test)#1 (1) { + ["prop"]=> + &string(1) "4" +} diff --git a/ext/intl/tests/intltz_get_canonical_id_refs.phpt b/ext/intl/tests/intltz_get_canonical_id_refs.phpt new file mode 100644 index 00000000000..973b7006c7d --- /dev/null +++ b/ext/intl/tests/intltz_get_canonical_id_refs.phpt @@ -0,0 +1,19 @@ +--TEST-- +IntlTimeZone::getCanonicalID: refs test +--EXTENSIONS-- +intl +--FILE-- +prop; +print_R(intltz_get_canonical_id('Portugal', $ref)); +var_dump($test); +?> +--EXPECT-- +Europe/Lisbonobject(Test)#1 (1) { + ["prop"]=> + &string(1) "1" +} 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 00000000000..06427a73693 --- /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 diff --git a/ext/intl/timezone/timezone_methods.cpp b/ext/intl/timezone/timezone_methods.cpp index 5d0a7dc445a..f652e9000c4 100644 --- a/ext/intl/timezone/timezone_methods.cpp +++ b/ext/intl/timezone/timezone_methods.cpp @@ -286,9 +286,7 @@ U_CFUNC PHP_FUNCTION(intltz_get_canonical_id) RETVAL_NEW_STR(u8str); if (is_systemid) { /* by-ref argument passed */ - ZVAL_DEREF(is_systemid); - zval_ptr_dtor(is_systemid); - ZVAL_BOOL(is_systemid, isSystemID); + ZEND_TRY_ASSIGN_REF_BOOL(is_systemid, isSystemID); } }