Skip to content

Commit 67b6331

Browse files
authored
Fix data tooltip panic (#123)
* 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. * Don't attempt to interpret wrongly sized data * Reference data display improvment issue * Log failure to display a symbol's value
1 parent 72ea1c8 commit 67b6331

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

objdiff-core/src/arch/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ 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+
// TODO: Attempt to interpret large symbols as arrays of a smaller type,
38+
// fallback to intrepreting it as bytes.
39+
// https://github.com/encounter/objdiff/issues/124
40+
if self.required_len().is_some_and(|l| bytes.len() != l) {
41+
log::warn!("Failed to display a symbol value for a symbol whose size doesn't match the instruction referencing it.");
3842
return None;
3943
}
4044

0 commit comments

Comments
 (0)