Skip to content

Commit

Permalink
Don't try to parse floats as strings
Browse files Browse the repository at this point in the history
  • Loading branch information
gheckenbachmz committed Sep 23, 2020
1 parent d30b6d0 commit 04f7e1e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/MockRedis.php
Original file line number Diff line number Diff line change
Expand Up @@ -1555,7 +1555,7 @@ public function spop($key, $count=null) {
} else {
$count = self::ParseInt($count);
$result = [];
for ($i = 0; $i < $count && count($set); $i++) {
for ($i = 0; $i < $count && count($set); $i++) {
$result[] = array_pop($set);
}
return $result;
Expand Down Expand Up @@ -2508,6 +2508,9 @@ private static function ParseFloat($value, $name='value') {
} elseif ($value === '-inf') {
return -INF;
}
if (is_int($value) || is_float($value)) {
return (float)$value;
}
if (!is_numeric($value) || $value[0] == ' ') {
throw self::ErrorReply("ERR $name is not a valid float or out of range");
}
Expand Down

0 comments on commit 04f7e1e

Please sign in to comment.