Skip to content

Commit

Permalink
check for underflow when calculating maximum address prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
matcap committed Jul 23, 2023
1 parent 78e0aad commit 4d79020
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/pretty_hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ where

let lines_len = lines.len();

let max_address = source.len() - cfg.width + cfg.display_offset;
let max_address = if source.len() <= cfg.width {
source.len() + cfg.display_offset
} else {
source.len() - cfg.width + cfg.display_offset
};
let write_address = get_address_writer(max_address);

for (i, row) in lines.enumerate() {
Expand Down

0 comments on commit 4d79020

Please sign in to comment.