Merge branch 'PHP-8.2' into PHP-8.3

* PHP-8.2:
  Fix reference handling in SpoofChecker
This commit is contained in:
Niels Dossche 2024-06-01 20:40:17 +02:00
commit c87f29f685
No known key found for this signature in database
GPG Key ID: B8A8AD166DF0E2E5
4 changed files with 58 additions and 6 deletions

3
NEWS
View File

@ -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

View File

@ -53,9 +53,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);
}
@ -87,9 +85,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);
}

View File

@ -0,0 +1,18 @@
--TEST--
SpoofChecker with self references
--EXTENSIONS--
intl
--FILE--
<?php
$checker = new Spoofchecker();
$checker->isSuspicious("", $checker);
$checker = new Spoofchecker();
$checker->areConfusable("", "", $checker);
echo "Done\n";
?>
--EXPECT--
Done

View File

@ -0,0 +1,35 @@
--TEST--
SpoofChecker with typed references
--EXTENSIONS--
intl
--FILE--
<?php
class Test {
public string $x;
}
$test = new Test;
$test->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"
}