Skip to content

Commit

Permalink
Fix warning on parse_bytes(null) call
Browse files Browse the repository at this point in the history
  • Loading branch information
alecpl committed Dec 17, 2023
1 parent 2546d2e commit 9729ff9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion program/lib/Roundcube/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function parse_bytes($str)

$bytes = 0;

if (preg_match('/([0-9\.]+)\s*([a-z]*)/i', $str, $regs)) {
if (preg_match('/([0-9\.]+)\s*([a-z]*)/i', (string) $str, $regs)) {
$bytes = floatval($regs[1]);
switch (strtolower($regs[2])) {
case 'g':
Expand Down
2 changes: 2 additions & 0 deletions tests/Framework/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ function test_parse_bytes()
$result = parse_bytes($value);
$this->assertEquals($expected, $result, "Invalid parse_bytes() result for $value");
}

$this->assertSame(0.0, parse_bytes(null));
}

/**
Expand Down

0 comments on commit 9729ff9

Please sign in to comment.