Skip to content

Commit 27125b8

Browse files
committed
Merge branch 'PHP-8.4'
2 parents a883082 + c82e31b commit 27125b8

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

ext/spl/spl_directory.c

+3
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,9 @@ PHP_METHOD(SplFileInfo, getPathInfo)
13681368

13691369
if (ce == NULL) {
13701370
ce = intern->info_class;
1371+
} else if (!instanceof_function(ce, spl_ce_SplFileInfo)) {
1372+
zend_argument_type_error(1, "must be a class name derived from %s or null, %s given", ZSTR_VAL(spl_ce_SplFileInfo->name), ZSTR_VAL(ce->name));
1373+
RETURN_THROWS();
13711374
}
13721375

13731376
path = spl_filesystem_object_get_pathname(intern);

ext/spl/tests/gh17516.phpt

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
GH-17516 SplTempFileObject::getPathInfo() crashes on invalid class ID.
3+
--FILE--
4+
<?php
5+
$cls = new SplTempFileObject();
6+
class SplFileInfoChild extends SplFileInfo {}
7+
class BadSplFileInfo {}
8+
9+
var_dump($cls->getPathInfo('SplFileInfoChild'));
10+
11+
try {
12+
$cls->getPathInfo('BadSplFileInfo');
13+
} catch (\TypeError $e) {
14+
echo $e->getMessage();
15+
}
16+
?>
17+
--EXPECT--
18+
object(SplFileInfoChild)#2 (2) {
19+
["pathName":"SplFileInfo":private]=>
20+
string(4) "php:"
21+
["fileName":"SplFileInfo":private]=>
22+
string(4) "php:"
23+
}
24+
SplFileInfo::getPathInfo(): Argument #1 ($class) must be a class name derived from SplFileInfo or null, BadSplFileInfo given

0 commit comments

Comments
 (0)