1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.3'

* PHP-8.3:
  Fix reference handling in SpoofChecker
This commit is contained in:
Niels Dossche
2024-06-01 20:45:01 +02:00
3 changed files with 55 additions and 6 deletions

View File

@@ -55,9 +55,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);
}
@@ -91,9 +89,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"
}