Skip to content

Commit ad37fc1

Browse files
Fix GH-15752: finfo_file() - parameter validation error message
Show the correct parameter name and number - the error is caused by the second parameter being empty, not the first.
1 parent 6cab769 commit ad37fc1

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

ext/fileinfo/fileinfo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ static void _php_finfo_get_type(INTERNAL_FUNCTION_PARAMETERS, int mode, int mime
374374
php_stream_statbuf ssb;
375375

376376
if (buffer == NULL || buffer_len == 0) {
377-
zend_argument_value_error(1, "cannot be empty");
377+
zend_argument_value_error(2, "cannot be empty");
378378
goto clean;
379379
}
380380
if (CHECK_NULL_PATH(buffer, buffer_len)) {

ext/fileinfo/tests/gh15752.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
GH-15752 (finfo_file() empty parameter name error)
3+
--EXTENSIONS--
4+
fileinfo
5+
--FILE--
6+
<?php
7+
8+
$info = finfo_open(FILEINFO_MIME_TYPE);
9+
10+
try {
11+
echo finfo_file($info, '') . "\n";
12+
} catch ( ValueError $e) {
13+
echo $e->getMessage(), "\n";
14+
}
15+
16+
?>
17+
--EXPECT--
18+
finfo_file(): Argument #2 ($filename) cannot be empty

0 commit comments

Comments
 (0)