From 1215361231b106428fcc6d03c0fa2d0cb818ecf5 Mon Sep 17 00:00:00 2001 From: NathanFreeman <1056159381@qq.com> Date: Wed, 22 Feb 2023 00:13:25 +0800 Subject: [PATCH 1/2] Fix bug #10647 --- ext/intl/spoofchecker/spoofchecker_main.c | 6 ++++-- ext/intl/tests/gh10647.phpt | 24 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 ext/intl/tests/gh10647.phpt diff --git a/ext/intl/spoofchecker/spoofchecker_main.c b/ext/intl/spoofchecker/spoofchecker_main.c index 35f7aef81022..a890f468e130 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 000000000000..4912f23c8818 --- /dev/null +++ b/ext/intl/tests/gh10647.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug GH-10647 (msgfmt_format $values may not support references) +--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) From 4c9f35a21de5ec34eff165b8623867a4408092a6 Mon Sep 17 00:00:00 2001 From: NathanFreeman <1056159381@qq.com> Date: Wed, 22 Feb 2023 00:16:41 +0800 Subject: [PATCH 2/2] rename --- ext/intl/tests/gh10647.phpt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/intl/tests/gh10647.phpt b/ext/intl/tests/gh10647.phpt index 4912f23c8818..61c6b87e0dde 100644 --- a/ext/intl/tests/gh10647.phpt +++ b/ext/intl/tests/gh10647.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug GH-10647 (msgfmt_format $values may not support references) +Bug GH-10647 (Spoofchecker::isSuspicious $errorCode always null) --SKIPIF--