summary history branches tags files
commit:de0cae508a3bad3278502deb88d8ca3f405c54b4
author:Trevor Bentley
committer:Trevor Bentley
date:Tue May 7 02:23:07 2024 +0200
parents:723fd612708434c285e40e4208c50803015d92e6
don't print beyond data length
diff --git a/src/lib.rs b/src/lib.rs
line changes: +2/-1
index 7b52ef6..0992c18
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -438,7 +438,8 @@ impl UsbmonPacket {
                     println!();
                     print!("                                        ")
                 }
-                for j in 0..16 {
+                let max = std::cmp::min(16, self.length_available() - i);
+                for j in 0..max {
                     print!("{:02x}", pkt_data[(i + j) as usize]);
                 }
             }