mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-22 08:51:05 +00:00
g_free() can handle NULL pointer
This commit is contained in:
parent
909bf43e77
commit
74986cc59a
|
@ -69,9 +69,7 @@ void memory_unmap(struct uc_struct *uc, MemoryRegion *mr)
|
||||||
//shift remainder of array down over deleted pointer
|
//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));
|
memcpy(&uc->mapped_blocks[i], &uc->mapped_blocks[i + 1], sizeof(MemoryRegion*) * (uc->mapped_block_count - i));
|
||||||
mr->destructor(mr);
|
mr->destructor(mr);
|
||||||
if((char *)mr->name)
|
|
||||||
g_free((char *)mr->name);
|
g_free((char *)mr->name);
|
||||||
if(mr->ioeventfds)
|
|
||||||
g_free(mr->ioeventfds);
|
g_free(mr->ioeventfds);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -81,12 +79,14 @@ void memory_unmap(struct uc_struct *uc, MemoryRegion *mr)
|
||||||
int memory_free(struct uc_struct *uc)
|
int memory_free(struct uc_struct *uc)
|
||||||
{
|
{
|
||||||
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;
|
uc->mapped_blocks[i]->enabled = false;
|
||||||
memory_region_del_subregion(get_system_memory(uc), uc->mapped_blocks[i]);
|
memory_region_del_subregion(get_system_memory(uc), uc->mapped_blocks[i]);
|
||||||
g_free(uc->mapped_blocks[i]);
|
g_free(uc->mapped_blocks[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
uc.c
2
uc.c
|
@ -277,9 +277,7 @@ uc_err uc_close(uc_engine *uc)
|
||||||
for (i = 0; i < uc->mapped_block_count; i++) {
|
for (i = 0; i < uc->mapped_block_count; i++) {
|
||||||
mr = uc->mapped_blocks[i];
|
mr = uc->mapped_blocks[i];
|
||||||
mr->destructor(mr);
|
mr->destructor(mr);
|
||||||
if((char *)mr->name)
|
|
||||||
g_free((char *)mr->name);
|
g_free((char *)mr->name);
|
||||||
if(mr->ioeventfds)
|
|
||||||
g_free(mr->ioeventfds);
|
g_free(mr->ioeventfds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue