Skip to content

Commit 462453c

Browse files
committed
Fix data tooltip panic
Prevents panicing when attempting to display the data tooltip for a symbol that is too large by just using as many bytes as needed from the begging of the symbol.
1 parent 72ea1c8 commit 462453c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

objdiff-core/src/arch/mod.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,12 @@ pub enum DataType {
3434

3535
impl DataType {
3636
pub fn display_bytes<Endian: ByteOrder>(&self, bytes: &[u8]) -> Option<String> {
37-
if self.required_len().is_some_and(|l| bytes.len() < l) {
37+
let Some(required_len) = self.required_len() else {
3838
return None;
39-
}
39+
};
40+
// TODO: For symbols larger than their data type, we should probably support
41+
// using the relocation's relative offset to read the bytes.
42+
let bytes = bytes.get(0..required_len)?;
4043

4144
match self {
4245
DataType::Int8 => {

0 commit comments

Comments
 (0)