mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fixed GH-18267 finfo_file() crashing on invalid URL protocol. (#18269)
Close GH-18267
This commit is contained in:
@@ -344,6 +344,9 @@ PHP_FUNCTION(finfo_file)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
php_stream_context *context = php_stream_context_from_zval(zcontext, false);
|
||||
if (!context) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
/* Set options for the current file/buffer. */
|
||||
if (options) {
|
||||
|
||||
14
ext/fileinfo/tests/gh18267.phpt
Normal file
14
ext/fileinfo/tests/gh18267.phpt
Normal file
@@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
GH-18267 finfo_file() assertion trigger on NULL stream context
|
||||
--EXTENSIONS--
|
||||
fileinfo
|
||||
--FILE--
|
||||
<?php
|
||||
$cls = new finfo();
|
||||
try {
|
||||
$cls->file("test",FILEINFO_NONE, STDERR);
|
||||
} catch (\TypeError $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
--EXPECT--
|
||||
finfo::file(): supplied resource is not a valid Stream-Context resource
|
||||
Reference in New Issue
Block a user