diff --git a/ext/intl/spoofchecker/spoofchecker_main.c b/ext/intl/spoofchecker/spoofchecker_main.c index 35f7aef810223..a890f468e130f 100644 --- a/ext/intl/spoofchecker/spoofchecker_main.c +++ b/ext/intl/spoofchecker/spoofchecker_main.c @@ -43,7 +43,8 @@ PHP_METHOD(Spoofchecker, isSuspicious) if (error_code) { zval_ptr_dtor(error_code); - ZVAL_LONG(error_code, ret); + ZVAL_LONG(Z_REFVAL_P(error_code), ret); + Z_TRY_ADDREF_P(error_code); } RETVAL_BOOL(ret != 0); } @@ -76,7 +77,8 @@ PHP_METHOD(Spoofchecker, areConfusable) if (error_code) { zval_ptr_dtor(error_code); - ZVAL_LONG(error_code, ret); + ZVAL_LONG(Z_REFVAL_P(error_code), ret); + Z_TRY_ADDREF_P(error_code); } RETVAL_BOOL(ret != 0); } diff --git a/ext/intl/tests/gh10647.phpt b/ext/intl/tests/gh10647.phpt new file mode 100644 index 0000000000000..61c6b87e0ddec --- /dev/null +++ b/ext/intl/tests/gh10647.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug GH-10647 (Spoofchecker::isSuspicious $errorCode always null) +--SKIPIF-- + +--FILE-- +isSuspicious("\u{041F}aypal.com", $error)); +var_dump($error); + +var_dump($x->areConfusable('google.com', 'goog1e.com', $error)); +var_dump($error); +?> +--EXPECTF-- +int(123) +bool(true) +int(%d) +bool(true) +int(%d)