mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-01-10 06:27:59 -05:00
GP-6136 fix ByteViewer exception when clicking on partial line
ByteViewer formats that use several bytes (eg. hex long, hex long long) cause a class cast exception when a row with partial data is displayed.
This commit is contained in:
@@ -566,18 +566,13 @@ public class ByteViewerComponent extends FieldPanel implements FieldMouseListene
|
||||
return characterOffset;
|
||||
}
|
||||
|
||||
int column = fieldLoc.getCol() + characterOffset;
|
||||
int fieldNum = fieldLoc.getFieldNum();
|
||||
int fieldRow = fieldLoc.getRow();
|
||||
ByteField field = (ByteField) layout.getField(fieldNum);
|
||||
if (field != null) {
|
||||
// not sure this can be null
|
||||
int numCols = field.getNumCols(fieldRow);
|
||||
if (column >= numCols) {
|
||||
column = numCols - 1;
|
||||
}
|
||||
if (!(layout.getField(fieldNum) instanceof ByteField field)) {
|
||||
return characterOffset;
|
||||
}
|
||||
|
||||
int column = Math.clamp(fieldLoc.getCol() + characterOffset, 0,
|
||||
field.getNumCols(fieldLoc.getRow()) - 1);
|
||||
return column;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user