Skip to content

Commit d83e006

Browse files
committed
change from review
1 parent 9b0fa9c commit d83e006

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

ext/fileinfo/fileinfo.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ static const char* php_fileinfo_from_path(struct magic_set *magic, const zend_st
283283
ZEND_ASSERT(path);
284284
ZEND_ASSERT(ZSTR_LEN(path) != 0);
285285
ZEND_ASSERT(!zend_str_has_nul_byte(path));
286+
ZEND_ASSERT(context != NULL);
286287

287288
/* determine if the file is a local file or remote URL */
288289
const char *dummy;
@@ -343,6 +344,9 @@ PHP_FUNCTION(finfo_file)
343344
RETURN_THROWS();
344345
}
345346
php_stream_context *context = php_stream_context_from_zval(zcontext, false);
347+
if (!context) {
348+
RETURN_THROWS();
349+
}
346350

347351
/* Set options for the current file/buffer. */
348352
if (options) {

ext/fileinfo/tests/gh18267.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ fileinfo
55
--FILE--
66
<?php
77
$cls = new finfo();
8-
$f = fopen("test", "r");
8+
$f = fopen("test", "w+");
99
try {
1010
$cls->file("test",FILEINFO_NONE, $f);
1111
} catch (\TypeError $e) {

0 commit comments

Comments
 (0)