Unified · Split
| @@ -23,8 +23,8 @@ impl Time { · 22 unmodified lines | ||
| 23 | 23 | |
| 24 | 24 | const ZERO: &[u8; 1] = b"0"; |
| 25 | 25 | |
| 26 | − const SECONDS_PER_HOUR: i32 = 60 * 60; | |
| 27 | − let offset = self.offset.abs(); | |
| 26 | + const SECONDS_PER_HOUR: u32 = 60 * 60; | |
| 27 | + let offset = self.offset.unsigned_abs(); | |
| 28 | 28 | let hours = offset / SECONDS_PER_HOUR; |
| 29 | 29 | assert!(hours < 25, "offset is more than a day: {hours}"); |
| 30 | 30 | let minutes = (offset - (hours * SECONDS_PER_HOUR)) / 60; |
| @@ -422,7 +422,7 @@ where · 421 unmodified lines | ||
| 422 | 422 | if n < 0 { |
| 423 | 423 | if name.is_empty() { |
| 424 | 424 | delegate |
| 425 | − .nth_checked_out_branch(n.abs().try_into().expect("non-negative isize fits usize")) | |
| 425 | + .nth_checked_out_branch(n.unsigned_abs()) | |
| 426 | 426 | .ok_or(Error::Delegate)?; |
| 427 | 427 | } else { |
| 428 | 428 | return Err(Error::RefnameNeedsPositiveReflogEntries { nav: nav.into() }); |
| @@ -10,6 +10,13 @@ fn braces_must_be_closed() { · 9 unmodified lines | ||
| 10 | 10 | } |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | +#[test] | |
| 14 | +#[cfg_attr(target_pointer_width = "32", ignore = "Only works this way on 64 bit systems")] | |
| 15 | +fn fuzzed() { | |
| 16 | + let rec = parse("@{-9223372036854775808}"); | |
| 17 | + assert_eq!(rec.nth_checked_out_branch, [Some(9223372036854775808), None]); | |
| 18 | +} | |
| 19 | + | |
| 13 | 20 | #[test] |
| 14 | 21 | fn reflog_by_entry_for_current_branch() { |
| 15 | 22 | for (spec, expected_entry) in [("@{0}", 0), ("@{42}", 42), ("@{00100}", 100)] { |