From 67b63311fc821178b168a3bd7a67068273d3badd Mon Sep 17 00:00:00 2001 From: Steven Casper Date: Tue, 15 Oct 2024 00:03:30 -0400 Subject: [PATCH] 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 --- objdiff-core/src/arch/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/objdiff-core/src/arch/mod.rs b/objdiff-core/src/arch/mod.rs index 7111341..494aff6 100644 --- a/objdiff-core/src/arch/mod.rs +++ b/objdiff-core/src/arch/mod.rs @@ -34,7 +34,11 @@ pub enum DataType { impl DataType { pub fn display_bytes(&self, bytes: &[u8]) -> Option { - if self.required_len().is_some_and(|l| bytes.len() < l) { + // TODO: Attempt to interpret large symbols as arrays of a smaller type, + // fallback to intrepreting it as bytes. + // https://github.com/encounter/objdiff/issues/124 + if self.required_len().is_some_and(|l| bytes.len() != l) { + log::warn!("Failed to display a symbol value for a symbol whose size doesn't match the instruction referencing it."); return None; }