diff --git a/qemu/memory.c b/qemu/memory.c index 74ea2cf8..8c5fd883 100755 --- a/qemu/memory.c +++ b/qemu/memory.c @@ -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; } diff --git a/regress/Makefile b/regress/Makefile index 06c5a31a..fccfa32c 100644 --- a/regress/Makefile +++ b/regress/Makefile @@ -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)