Skip to content

Commit c87f29f

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix reference handling in SpoofChecker
2 parents 98c8518 + 5ec26ed commit c87f29f

File tree

4 files changed

+58
-6
lines changed

4 files changed

+58
-6
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ PHP NEWS
1818
- DOM:
1919
. Fixed bug GH-14343 (Memory leak in xml and dom). (nielsdos)
2020

21+
- Intl:
22+
. Fix reference handling in SpoofChecker. (nielsdos)
23+
2124
- MySQLnd:
2225
. Partially fix bug GH-10599 (Apache crash on Windows when using a
2326
self-referencing anonymous function inside a class with an active

ext/intl/spoofchecker/spoofchecker_main.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ PHP_METHOD(Spoofchecker, isSuspicious)
5353
}
5454

5555
if (error_code) {
56-
zval_ptr_dtor(error_code);
57-
ZVAL_LONG(Z_REFVAL_P(error_code), ret);
58-
Z_TRY_ADDREF_P(error_code);
56+
ZEND_TRY_ASSIGN_REF_LONG(error_code, ret);
5957
}
6058
RETVAL_BOOL(ret != 0);
6159
}
@@ -87,9 +85,7 @@ PHP_METHOD(Spoofchecker, areConfusable)
8785
}
8886

8987
if (error_code) {
90-
zval_ptr_dtor(error_code);
91-
ZVAL_LONG(Z_REFVAL_P(error_code), ret);
92-
Z_TRY_ADDREF_P(error_code);
88+
ZEND_TRY_ASSIGN_REF_LONG(error_code, ret);
9389
}
9490
RETVAL_BOOL(ret != 0);
9591
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
SpoofChecker with self references
3+
--EXTENSIONS--
4+
intl
5+
--FILE--
6+
<?php
7+
8+
$checker = new Spoofchecker();
9+
$checker->isSuspicious("", $checker);
10+
11+
$checker = new Spoofchecker();
12+
$checker->areConfusable("", "", $checker);
13+
14+
echo "Done\n";
15+
16+
?>
17+
--EXPECT--
18+
Done
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
--TEST--
2+
SpoofChecker with typed references
3+
--EXTENSIONS--
4+
intl
5+
--FILE--
6+
<?php
7+
8+
class Test {
9+
public string $x;
10+
}
11+
12+
$test = new Test;
13+
$test->x = "";
14+
15+
$checker = new Spoofchecker();
16+
$checker->isSuspicious("", $test->x);
17+
var_dump($test);
18+
19+
$test = new Test;
20+
$test->x = "";
21+
22+
$checker = new Spoofchecker();
23+
$checker->areConfusable("", "", $test->x);
24+
var_dump($test);
25+
26+
?>
27+
--EXPECT--
28+
object(Test)#1 (1) {
29+
["x"]=>
30+
string(1) "0"
31+
}
32+
object(Test)#3 (1) {
33+
["x"]=>
34+
string(1) "1"
35+
}

0 commit comments

Comments
 (0)