Skip to content

Commit e039aff

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
2 parents ed21ebd + eeec093 commit e039aff

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ PHP NEWS
115115
. Fix GH-16477 (Segmentation fault when calling __debugInfo() after failed
116116
SplFileObject::__constructor). (Girgias)
117117
. Fixed bug GH-16589 (UAF in SplDoublyLinked->serialize()). (nielsdos)
118+
. Fixed bug GH-14687 (segfault on SplObjectIterator instance).
119+
(David Carlier)
118120

119121
- Standard:
120122
. Fixed bug GH-16293 (Failed assertion when throwing in assert() callback with

ext/spl/spl_directory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ static inline HashTable *spl_filesystem_object_get_debug_info(zend_object *objec
658658
if (intern->type == SPL_FS_DIR) {
659659
#ifdef HAVE_GLOB
660660
pnstr = spl_gen_private_prop_name(spl_ce_DirectoryIterator, "glob", sizeof("glob")-1);
661-
if (php_stream_is(intern->u.dir.dirp ,&php_glob_stream_ops)) {
661+
if (intern->u.dir.dirp && php_stream_is(intern->u.dir.dirp ,&php_glob_stream_ops)) {
662662
ZVAL_STR_COPY(&tmp, intern->path);
663663
} else {
664664
ZVAL_FALSE(&tmp);

ext/spl/tests/gh14687.phpt

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
--TEST--
2+
GH-14687 segfault on debugging SplObjectStorage instance after __destruct.
3+
--CREDITS--
4+
YuanchengJiang
5+
--EXTENSIONS--
6+
phar
7+
--INI--
8+
phar.require_hash=0
9+
phar.readonly=0
10+
--FILE--
11+
<?php
12+
$fname = __DIR__ . '/gh14687.phar.zip';
13+
$phar = new Phar($fname);
14+
class HasDestructor {
15+
public function __destruct() {
16+
var_dump($GLOBALS['s']);
17+
}
18+
}
19+
$s = new SplObjectStorage();
20+
$s[$phar] = new HasDestructor();
21+
register_shutdown_function(function() {
22+
global $s;
23+
});
24+
?>
25+
--CLEAN--
26+
<?php
27+
@unlink(__DIR__ . '/gh14687.phar.zip');
28+
?>
29+
--EXPECT--
30+
object(SplObjectStorage)#2 (1) {
31+
["storage":"SplObjectStorage":private]=>
32+
array(1) {
33+
[0]=>
34+
array(2) {
35+
["obj"]=>
36+
object(Phar)#1 (3) {
37+
["pathName":"SplFileInfo":private]=>
38+
string(0) ""
39+
["glob":"DirectoryIterator":private]=>
40+
bool(false)
41+
["subPathName":"RecursiveDirectoryIterator":private]=>
42+
string(0) ""
43+
}
44+
["inf"]=>
45+
object(HasDestructor)#3 (0) {
46+
}
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)