File tree 2 files changed +6
-5
lines changed
2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -574,8 +574,8 @@ PHP_FUNCTION(random_bytes)
574
574
Z_PARAM_LONG (size )
575
575
ZEND_PARSE_PARAMETERS_END ();
576
576
577
- if (size < 1 ) {
578
- zend_argument_value_error (1 , "must be greater than 0" );
577
+ if (size < 0 ) {
578
+ zend_argument_value_error (1 , "must be greater than or equal to 0" );
579
579
RETURN_THROWS ();
580
580
}
581
581
Original file line number Diff line number Diff line change @@ -3,20 +3,21 @@ Test error operation of random_bytes()
3
3
--FILE--
4
4
<?php
5
5
//-=-=-=-
6
-
6
+ var_dump ( random_bytes ( 0 ));
7
7
try {
8
8
$ bytes = random_bytes ();
9
9
} catch (TypeError $ e ) {
10
10
echo $ e ->getMessage ().PHP_EOL ;
11
11
}
12
12
13
13
try {
14
- $ bytes = random_bytes (0 );
14
+ $ bytes = random_bytes (- 1 );
15
15
} catch (Error $ e ) {
16
16
echo $ e ->getMessage ().PHP_EOL ;
17
17
}
18
18
19
19
?>
20
20
--EXPECT--
21
+ string(0) ""
21
22
random_bytes() expects exactly 1 argument, 0 given
22
- random_bytes(): Argument #1 ($length) must be greater than 0
23
+ random_bytes(): Argument #1 ($length) must be greater than or equal to 0
You can’t perform that action at this time.
0 commit comments