GP-1778 fixing bug introduced by changes in GP-1778

This commit is contained in:
ghidravore 2022-05-03 13:43:20 -04:00
parent d003cf532f
commit e8ad3efcda
2 changed files with 20 additions and 5 deletions

View File

@ -921,6 +921,20 @@ public abstract class AbstractAddressRangeMapTest extends AbstractGhidraHeadedIn
}
@Test
public void testClearRangeThatEndsAtMaxAddress() {
AddressRange range1 = range(spaceMax.subtract(0x100), spaceMax);
map.paintRange(range1.getMinAddress(), range1.getMaxAddress(), ONE);
assertEquals(1, map.getRecordCount());
assertEquals(1, getMapRanges().size());
assertEquals(range1, getMapRanges().get(0));
map.clearRange(addr(0), spaceMax);
List<AddressRange> ranges = getMapRanges();
assertEquals(0, ranges.size());
}
private AddressRange range(Address start, Address end) {
return new AddressRangeImpl(start, end);
}

View File

@ -752,15 +752,16 @@ public class AddressRangeMapDB implements DBListener {
while (it.hasNext()) {
DBRecord record = it.next();
it.delete(); // all the records that start in the paint region need to be deleted
Address endAddress = getEndAddress(record);
if (endAddress.compareTo(endAddr) >= 0) {
Address recordEndAddress = getEndAddress(record);
if (recordEndAddress.compareTo(endAddr) > 0) {
Field recordValue = getValue(record);
if (recordValue.equals(value)) {
// since the last record has same value, it extends our paintRange
return endAddress;
return recordEndAddress;
}
// the last record extended past the paint range, create a remainder record
createRecord(endAddr.add(1), endAddress, recordValue);
// the last record extended past the paint range with a different value,
// create a remainder record
createRecord(endAddr.add(1), recordEndAddress, recordValue);
}
}
return endAddr;