aboutsummaryrefslogtreecommitdiff
path: root/lib/xixanta/src
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mssola@mssola.com>2026-07-09 22:15:43 +0200
committerMiquel Sabaté Solà <mssola@mssola.com>2026-07-09 22:15:43 +0200
commit426aa0d30b9e708ccb4072a17ade49bf5a245d63 (patch)
tree6fc80919fed45dcad6e7369a94015101cc9e3310 /lib/xixanta/src
parent7b83a222ee52c579d127ec40701c57b5576ddf71 (diff)
downloadtools.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/xixanta/src')
-rw-r--r--lib/xixanta/src/assembler.rs2
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);
}