Skip to content

Commit 4fb80c5

Browse files
committed
Fixed GH-18267 finfo_file() crashing on invalid URL protocol.
1 parent ea6f2fb commit 4fb80c5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/fileinfo/fileinfo.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,6 @@ 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);
287286

288287
/* determine if the file is a local file or remote URL */
289288
const char *dummy;
@@ -293,6 +292,8 @@ static const char* php_fileinfo_from_path(struct magic_set *magic, const zend_st
293292
if (UNEXPECTED(wrap == NULL)) {
294293
return NULL;
295294
}
295+
/* we need the stream context when there is an appropriate URL protocol */
296+
ZEND_ASSERT(context != NULL);
296297

297298
#ifdef PHP_WIN32
298299
if (php_stream_stat_path_ex(ZSTR_VAL(path), 0, &ssb, context) == SUCCESS) {

0 commit comments

Comments
 (0)