mirror of
https://github.com/php/php-src.git
synced 2025-08-17 14:38:49 +02:00
Promote empty filename to ValueError in BZ2 extension
This commit is contained in:
parent
c3105a1f8d
commit
4095c0a28d
2 changed files with 20 additions and 19 deletions
|
@ -350,7 +350,7 @@ PHP_FUNCTION(bzopen)
|
|||
/* If it's not a resource its a string containing the filename to open */
|
||||
if (Z_TYPE_P(file) == IS_STRING) {
|
||||
if (Z_STRLEN_P(file) == 0) {
|
||||
php_error_docref(NULL, E_WARNING, "Filename cannot be empty");
|
||||
zend_argument_value_error(1, "cannot be empty");
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,44 +6,45 @@ bzopen() and invalid parameters
|
|||
<?php
|
||||
|
||||
try {
|
||||
var_dump(bzopen("", ""));
|
||||
} catch (\ValueError $e) {
|
||||
echo $e->getMessage() . \PHP_EOL;
|
||||
}
|
||||
|
||||
var_dump(bzopen("", "r"));
|
||||
var_dump(bzopen("", "w"));
|
||||
|
||||
try {
|
||||
var_dump(bzopen("", "x"));
|
||||
var_dump(bzopen("", "r"));
|
||||
} catch (\ValueError $e) {
|
||||
echo $e->getMessage() . \PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
var_dump(bzopen("", "rw"));
|
||||
var_dump(bzopen("", "w"));
|
||||
} catch (\ValueError $e) {
|
||||
echo $e->getMessage() . \PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
var_dump(bzopen("no_such_file", "r"));
|
||||
var_dump(bzopen("no_such_file", ""));
|
||||
} catch (\ValueError $e) {
|
||||
echo $e->getMessage() . \PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
var_dump(bzopen("no_such_file", "x"));
|
||||
} catch (\ValueError $e) {
|
||||
echo $e->getMessage() . \PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
var_dump(bzopen("no_such_file", "rw"));
|
||||
} catch (\ValueError $e) {
|
||||
echo $e->getMessage() . \PHP_EOL;
|
||||
}
|
||||
|
||||
var_dump(bzopen("no_such_file", "r"));
|
||||
|
||||
$fp = fopen(__FILE__,"r");
|
||||
var_dump(bzopen($fp, "r"));
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
bzopen(): Argument #1 ($file) cannot be empty
|
||||
bzopen(): Argument #1 ($file) cannot be empty
|
||||
bzopen(): Argument #2 ($mode) must be either "r" or "w"
|
||||
|
||||
Warning: bzopen(): Filename cannot be empty in %s on line %d
|
||||
bool(false)
|
||||
|
||||
Warning: bzopen(): Filename cannot be empty in %s on line %d
|
||||
bool(false)
|
||||
bzopen(): Argument #2 ($mode) must be either "r" or "w"
|
||||
bzopen(): Argument #2 ($mode) must be either "r" or "w"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue