We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent aa0c54d commit 2d39c78Copy full SHA for 2d39c78
ext/fileinfo/fileinfo.c
@@ -344,6 +344,9 @@ PHP_FUNCTION(finfo_file)
344
RETURN_THROWS();
345
}
346
php_stream_context *context = php_stream_context_from_zval(zcontext, false);
347
+ if (!context) {
348
+ RETURN_THROWS();
349
+ }
350
351
/* Set options for the current file/buffer. */
352
if (options) {
ext/fileinfo/tests/gh18267.phpt
@@ -0,0 +1,14 @@
1
+--TEST--
2
+GH-18267 finfo_file() assertion trigger on NULL stream context
3
+--EXTENSIONS--
4
+fileinfo
5
+--FILE--
6
+<?php
7
+$cls = new finfo();
8
+try {
9
+ $cls->file("test",FILEINFO_NONE, STDERR);
10
+} catch (\TypeError $e) {
11
+ echo $e->getMessage();
12
+}
13
+--EXPECT--
14
+finfo::file(): supplied resource is not a valid Stream-Context resource
0 commit comments