fix: clear sufficient space when changing data types
When applying a larger struct to an address, clear enough space for the new data type rather than just the old data's length. This prevents 'Conflicting data exists' errors when the new type is larger than the existing data. Fixes issue where ConfigParametersStruct couldn't be applied due to conflicting smaller data items in the address range.
This commit is contained in:
parent
f32dc5504c
commit
60124d2315
@ -533,9 +533,14 @@ package eu.starsong.ghidra.endpoints;
|
||||
throw new Exception("Could not find or parse data type: " + dataTypeStr);
|
||||
}
|
||||
|
||||
// Clear existing data
|
||||
int length = data.getLength();
|
||||
listing.clearCodeUnits(addr, addr.add(length - 1), false);
|
||||
// Clear existing data - need to clear enough space for the new data type
|
||||
// Use the LARGER of the old data length or new data type length
|
||||
int oldLength = data.getLength();
|
||||
int newLength = dataType.getLength();
|
||||
int lengthToClear = Math.max(oldLength, newLength > 0 ? newLength : oldLength);
|
||||
|
||||
// Clear the required space
|
||||
listing.clearCodeUnits(addr, addr.add(lengthToClear - 1), false);
|
||||
|
||||
// Create new data
|
||||
Data newData = listing.createData(addr, dataType);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user