Fix segfault introduced in my previous commits.

This commit is contained in:
farmdve 2015-12-11 22:35:25 +02:00
parent f21fa3d966
commit 8b79a872d0
2 changed files with 8 additions and 11 deletions

View file

@ -78,13 +78,18 @@ void memory_unmap(struct uc_struct *uc, MemoryRegion *mr)
int memory_free(struct uc_struct *uc) int memory_free(struct uc_struct *uc)
{ {
MemoryRegion *mr;
int i; int i;
get_system_memory(uc)->enabled = false; get_system_memory(uc)->enabled = false;
for (i = 0; i < uc->mapped_block_count; i++) { for (i = 0; i < uc->mapped_block_count; i++) {
uc->mapped_blocks[i]->enabled = false; mr = uc->mapped_blocks[i];
memory_region_del_subregion(get_system_memory(uc), uc->mapped_blocks[i]); mr->enabled = false;
g_free(uc->mapped_blocks[i]); memory_region_del_subregion(get_system_memory(uc), mr);
mr->destructor(mr);
g_free((char *)mr->name);
g_free(mr->ioeventfds);
g_free(mr);
} }
return 0; return 0;

8
uc.c
View file

@ -258,7 +258,6 @@ uc_err uc_open(uc_arch arch, uc_mode mode, uc_engine **result)
UNICORN_EXPORT UNICORN_EXPORT
uc_err uc_close(uc_engine *uc) uc_err uc_close(uc_engine *uc)
{ {
MemoryRegion *mr;
int i; int i;
if (uc->release) if (uc->release)
@ -274,13 +273,6 @@ uc_err uc_close(uc_engine *uc)
g_free(uc->tcg_ctx); g_free(uc->tcg_ctx);
for (i = 0; i < uc->mapped_block_count; i++) {
mr = uc->mapped_blocks[i];
mr->destructor(mr);
g_free((char *)mr->name);
g_free(mr->ioeventfds);
}
free((void*) uc->system_memory->name); free((void*) uc->system_memory->name);
g_free(uc->system_memory); g_free(uc->system_memory);
g_hash_table_destroy(uc->type_table); g_hash_table_destroy(uc->type_table);