Skip to content

Commit f9c6780

Browse files
committed
Workaround deliberate overflowing negation in serialize::json.
1 parent e5a3600 commit f9c6780

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/libserialize/json.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,8 @@ impl<T: Iterator<Item=char>> Parser<T> {
15401540
F64Value(res)
15411541
} else {
15421542
if neg {
1543-
let res = -(res as i64);
1543+
// FIXME (#24420) use wrapping_neg instead after it lands.
1544+
let res = !(res as i64).wrapping_add(1);
15441545

15451546
// Make sure we didn't underflow.
15461547
if res > 0 {

0 commit comments

Comments
 (0)