mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-24 07:38:11 +00:00
memory: Protect against use-after-free
This commit is contained in:
parent
309b85548f
commit
43fe0c8a1c
1 changed files with 2 additions and 0 deletions
|
@ -97,6 +97,7 @@ void memory_unmap(struct uc_struct *uc, MemoryRegion *mr)
|
|||
//shift remainder of array down over deleted pointer
|
||||
memmove(&uc->mapped_blocks[i], &uc->mapped_blocks[i + 1], sizeof(MemoryRegion*) * (uc->mapped_block_count - i));
|
||||
mr->destructor(mr);
|
||||
mr->ram_block = NULL;
|
||||
obj = OBJECT(mr);
|
||||
obj->ref = 1;
|
||||
obj->free = g_free;
|
||||
|
@ -119,6 +120,7 @@ int memory_free(struct uc_struct *uc)
|
|||
mr->enabled = false;
|
||||
memory_region_del_subregion(get_system_memory(uc), mr);
|
||||
mr->destructor(mr);
|
||||
mr->ram_block = NULL;
|
||||
obj = OBJECT(mr);
|
||||
obj->ref = 1;
|
||||
obj->free = g_free;
|
||||
|
|
Loading…
Reference in a new issue