diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-07-09 22:15:43 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-07-09 22:15:43 +0200 |
| commit | 426aa0d30b9e708ccb4072a17ade49bf5a245d63 (patch) | |
| tree | 6fc80919fed45dcad6e7369a94015101cc9e3310 /lib | |
| parent | 7b83a222ee52c579d127ec40701c57b5576ddf71 (diff) | |
| download | tools.nes-426aa0d30b9e708ccb4072a17ade49bf5a245d63.tar.gz tools.nes-426aa0d30b9e708ccb4072a17ade49bf5a245d63.zip | |
Prevent out of bounds panics on range_to_human()
On range_to_human(), if the range is completely broken for some reason,
we might get a start = 0 and end = 0. In this case, then we would get
into an 'end - 1' computation for an 'usize', resulting in bad
arithmetics.
This can be avoided altogether if the 'start + 1' computation from the
start of the function not only results to be equal, but also larger than
'end'. This, of course, doesn't make much sense, and it's most probably
a bandaid; but it has been detected via fuzzy testing with wild
inputs. Hence, it's fine if this function doesn't return a coherent
string representation for deranged inputs.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/xixanta/src/assembler.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/xixanta/src/assembler.rs b/lib/xixanta/src/assembler.rs index 26d12b2..02414a7 100644 --- a/lib/xixanta/src/assembler.rs +++ b/lib/xixanta/src/assembler.rs @@ -83,7 +83,7 @@ impl MemoryRange { /// Display the range in hexadecimal format and by taking into consideration /// on whether it's really a range or a single value. pub fn range_to_human(&self) -> String { - if self.range.start + 1 == self.range.end { + if self.range.start + 1 >= self.range.end { if self.range.start <= 0xFF { return format!("${:02X}", self.range.start); } |
