diff --git a/NEWS b/NEWS index 51564ad4263..aaf02438081 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,9 @@ PHP NEWS - DOM: . Fixed bug GH-14343 (Memory leak in xml and dom). (nielsdos) +- Intl: + . Fix reference handling in SpoofChecker. (nielsdos) + - MySQLnd: . Partially fix bug GH-10599 (Apache crash on Windows when using a self-referencing anonymous function inside a class with an active diff --git a/ext/intl/spoofchecker/spoofchecker_main.c b/ext/intl/spoofchecker/spoofchecker_main.c index a890f468e13..9863ee5e5ce 100644 --- a/ext/intl/spoofchecker/spoofchecker_main.c +++ b/ext/intl/spoofchecker/spoofchecker_main.c @@ -42,9 +42,7 @@ PHP_METHOD(Spoofchecker, isSuspicious) } if (error_code) { - zval_ptr_dtor(error_code); - ZVAL_LONG(Z_REFVAL_P(error_code), ret); - Z_TRY_ADDREF_P(error_code); + ZEND_TRY_ASSIGN_REF_LONG(error_code, ret); } RETVAL_BOOL(ret != 0); } @@ -76,9 +74,7 @@ PHP_METHOD(Spoofchecker, areConfusable) } if (error_code) { - zval_ptr_dtor(error_code); - ZVAL_LONG(Z_REFVAL_P(error_code), ret); - Z_TRY_ADDREF_P(error_code); + ZEND_TRY_ASSIGN_REF_LONG(error_code, ret); } RETVAL_BOOL(ret != 0); } diff --git a/ext/intl/tests/spoofchecker_self_references.phpt b/ext/intl/tests/spoofchecker_self_references.phpt new file mode 100644 index 00000000000..d2feaa77a32 --- /dev/null +++ b/ext/intl/tests/spoofchecker_self_references.phpt @@ -0,0 +1,18 @@ +--TEST-- +SpoofChecker with self references +--EXTENSIONS-- +intl +--FILE-- +isSuspicious("", $checker); + +$checker = new Spoofchecker(); +$checker->areConfusable("", "", $checker); + +echo "Done\n"; + +?> +--EXPECT-- +Done diff --git a/ext/intl/tests/spoofchecker_typed_references.phpt b/ext/intl/tests/spoofchecker_typed_references.phpt new file mode 100644 index 00000000000..5508497072d --- /dev/null +++ b/ext/intl/tests/spoofchecker_typed_references.phpt @@ -0,0 +1,35 @@ +--TEST-- +SpoofChecker with typed references +--EXTENSIONS-- +intl +--FILE-- +x = ""; + +$checker = new Spoofchecker(); +$checker->isSuspicious("", $test->x); +var_dump($test); + +$test = new Test; +$test->x = ""; + +$checker = new Spoofchecker(); +$checker->areConfusable("", "", $test->x); +var_dump($test); + +?> +--EXPECT-- +object(Test)#1 (1) { + ["x"]=> + string(1) "0" +} +object(Test)#3 (1) { + ["x"]=> + string(1) "1" +}