GT-3073 fixed bug in put byte when there is more than one sub block in a

memory block
This commit is contained in:
ghidravore 2019-08-12 13:53:28 -04:00
parent e36b22d268
commit 0af34a4197
2 changed files with 12 additions and 1 deletions

View file

@ -454,7 +454,7 @@ public class MemoryBlockDB implements MemoryBlock {
SubMemoryBlock subBlock = getSubBlock(offset);
memMap.lock.acquire();
try {
subBlock.putByte(offset - subBlock.getStartingOffset(), b);
subBlock.putByte(offset, b);
}
catch (IOException e) {
memMap.dbError(e);

View file

@ -631,6 +631,17 @@ public class MemBlockDBTest extends AbstractGenericTest {
assertEquals(-1, block.getByte(addr(0)));
}
@Test
public void testSetBytesInSubBlocks() throws Exception {
FileBytes fileBytes = createFileBytes();
MemoryBlock block1 = createFileBytesBlock(fileBytes, addr(0), 0, 10);
MemoryBlock block2 = createFileBytesBlock(fileBytes, addr(10), 20, 10);
mem.join(block1, block2);
assertEquals(20, mem.getByte(addr(10)));
mem.setByte(addr(10), (byte) 0);
assertEquals(0, mem.getByte(addr(10)));
}
@Test
public void testBitMappedJoin() throws Exception {
FileBytes fileBytes = createFileBytes();