Error when parsing numbers outside of f64's range

This commit is contained in:
Alan Du 2017-05-31 00:07:15 +01:00
parent 5170d66d51
commit 90040b34b6
2 changed files with 10 additions and 0 deletions

View file

@ -893,6 +893,12 @@ impl<'a> Deserializer<'a> {
}
number.parse().map_err(|_e| {
self.error(start, ErrorKind::NumberInvalid)
}).and_then(|n: f64| {
if n.is_finite() {
Ok(n)
} else {
Err(self.error(start, ErrorKind::NumberInvalid))
}
})
}

View file

@ -10,4 +10,8 @@ fn bad() {
bad("a = 1__1");
bad("a = 1_");
bad("''");
bad("a = nan");
bad("a = -inf");
bad("a = inf");
bad("a = 9e99999");
}