提交 7c8edaba 编写于 作者: F Felix S. Klock II

Accommodate arith-overflow in serialize::json numeric parsing.

上级 c8db89aa
......@@ -1569,8 +1569,8 @@ fn parse_u64(&mut self) -> Result<u64, ParserError> {
while !self.eof() {
match self.ch_or_null() {
c @ '0' ... '9' => {
accum *= 10;
accum += (c as u64) - ('0' as u64);
accum = accum.wrapping_mul(10);
accum = accum.wrapping_add((c as u64) - ('0' as u64));
// Detect overflow by comparing to the last value.
if accum <= last_accum { return self.error(InvalidNumber); }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册