Free up all MemoryRegion* when uc is closed

This commit is contained in:
Chris Eagle 2015-08-26 14:09:46 -07:00
parent 00944b6cde
commit 4b529bc56c
2 changed files with 6 additions and 5 deletions

View File

@ -47,11 +47,12 @@ MemoryRegion *memory_map(struct uc_struct *uc, ram_addr_t begin, size_t size, ui
int memory_free(struct uc_struct *uc)
{
int i;
get_system_memory(uc)->enabled = false;
if (uc->ram) {
uc->ram->enabled = false;
memory_region_del_subregion(get_system_memory(uc), uc->ram);
g_free(uc->ram);
for (i = 0; i < uc->mapped_block_count; i++) {
uc->mapped_blocks[i].region->enabled = false;
memory_region_del_subregion(get_system_memory(uc), uc->mapped_blocks[i].region);
g_free(uc->mapped_blocks[i].region);
}
return 0;
}

View File

@ -1,7 +1,7 @@
CFLAGS += -I../include
LDFLAGS = -L.. -lunicorn
TESTS = map_crash sigill sigill2 block_test
TESTS = map_crash sigill sigill2 block_test ro_mem_test
all: $(TESTS)