Skip to content

Commit

Permalink
Fix data tooltip panic (#123)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
SquareMan authored Oct 15, 2024
1 parent 72ea1c8 commit 67b6331
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion objdiff-core/src/arch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ pub enum DataType {

impl DataType {
pub fn display_bytes<Endian: ByteOrder>(&self, bytes: &[u8]) -> Option<String> {
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;
}

Expand Down

0 comments on commit 67b6331

Please sign in to comment.