diff options
| author | bors <bors@rust-lang.org> | 2015-03-03 14:18:03 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-03-03 14:18:03 +0000 | 
| commit | 14f0942a49b77f81d0bedb3d8b5fb615ef521bb3 (patch) | |
| tree | fa3cabf0f4e563a1b4f9e40fafa4855e905fd8e7 /src/libserialize/json.rs | |
| parent | 38e97b99a6b133cb4c621c68e75b28abc6c617c1 (diff) | |
| parent | 243c5164ea32b38c4ac44fdd5e0ceb2da45c283f (diff) | |
| download | rust-14f0942a49b77f81d0bedb3d8b5fb615ef521bb3.tar.gz rust-14f0942a49b77f81d0bedb3d8b5fb615ef521bb3.zip | |
Auto merge of #22532 - pnkfelix:arith-overflow, r=pnkfelix,eddyb
Rebase and follow-through on work done by @cmr and @aatch. Implements most of rust-lang/rfcs#560. Errors encountered from the checks during building were fixed. The checks for division, remainder and bit-shifting have not been implemented yet. See also PR #20795 cc @Aatch ; cc @nikomatsakis
Diffstat (limited to 'src/libserialize/json.rs')
| -rw-r--r-- | src/libserialize/json.rs | 4 | 
1 files changed, 2 insertions, 2 deletions
| diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 14930f91c91..bf4d006fcfa 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -1569,8 +1569,8 @@ impl<T: Iterator<Item=char>> Parser<T> { 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); } | 
