mirror of
https://github.com/Cxbx-Reloaded/unicorn.git
synced 2024-12-04 01:11:10 +00:00
g_free() can handle NULL pointer
This commit is contained in:
parent
909bf43e77
commit
74986cc59a
@ -69,10 +69,8 @@ void memory_unmap(struct uc_struct *uc, MemoryRegion *mr)
|
||||
//shift remainder of array down over deleted pointer
|
||||
memcpy(&uc->mapped_blocks[i], &uc->mapped_blocks[i + 1], sizeof(MemoryRegion*) * (uc->mapped_block_count - i));
|
||||
mr->destructor(mr);
|
||||
if((char *)mr->name)
|
||||
g_free((char *)mr->name);
|
||||
if(mr->ioeventfds)
|
||||
g_free(mr->ioeventfds);
|
||||
g_free((char *)mr->name);
|
||||
g_free(mr->ioeventfds);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -81,12 +79,14 @@ void memory_unmap(struct uc_struct *uc, MemoryRegion *mr)
|
||||
int memory_free(struct uc_struct *uc)
|
||||
{
|
||||
int i;
|
||||
|
||||
get_system_memory(uc)->enabled = false;
|
||||
for (i = 0; i < uc->mapped_block_count; i++) {
|
||||
uc->mapped_blocks[i]->enabled = false;
|
||||
memory_region_del_subregion(get_system_memory(uc), uc->mapped_blocks[i]);
|
||||
g_free(uc->mapped_blocks[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
6
uc.c
6
uc.c
@ -277,10 +277,8 @@ uc_err uc_close(uc_engine *uc)
|
||||
for (i = 0; i < uc->mapped_block_count; i++) {
|
||||
mr = uc->mapped_blocks[i];
|
||||
mr->destructor(mr);
|
||||
if((char *)mr->name)
|
||||
g_free((char *)mr->name);
|
||||
if(mr->ioeventfds)
|
||||
g_free(mr->ioeventfds);
|
||||
g_free((char *)mr->name);
|
||||
g_free(mr->ioeventfds);
|
||||
}
|
||||
|
||||
free((void*) uc->system_memory->name);
|
||||
|
Loading…
Reference in New Issue
Block a user