fix panic if len is zero

This commit is contained in:
Numbers
2025-06-02 09:57:38 +02:00
parent d4b8ef032b
commit fa11367d84

View File

@@ -45,6 +45,12 @@ impl<'s, T: Scannable + ?Sized, R: RangeBounds<usize>> Display for HexDump<'s, T
(start, end)
};
// if there is nothing to print then just return...
// this also prevents the ilog below from crashing :)
if end == 0 || start > end {
return Ok(())
}
// the number of digits the address column should have
let digits = (end.ilog(16) as usize + 1).max(4);