mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-03 17:25:30 +00:00
do not abort() when memory is insufficient. this fixes issue #244
This commit is contained in:
parent
87ce40eb00
commit
272293556a
|
@ -1083,6 +1083,7 @@ static ram_addr_t ram_block_add(struct uc_struct *uc, RAMBlock *new_block, Error
|
|||
return new_block->offset;
|
||||
}
|
||||
|
||||
// return -1 on error
|
||||
ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
|
||||
MemoryRegion *mr, Error **errp)
|
||||
{
|
||||
|
@ -1092,6 +1093,9 @@ ram_addr_t qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
|
|||
|
||||
size = TARGET_PAGE_ALIGN(size);
|
||||
new_block = g_malloc0(sizeof(*new_block));
|
||||
if (new_block == NULL)
|
||||
return -1;
|
||||
|
||||
new_block->mr = mr;
|
||||
new_block->length = size;
|
||||
new_block->fd = -1;
|
||||
|
|
|
@ -36,6 +36,9 @@ MemoryRegion *memory_map(struct uc_struct *uc, ram_addr_t begin, size_t size, ui
|
|||
MemoryRegion *ram = g_new(MemoryRegion, 1);
|
||||
|
||||
memory_region_init_ram(uc, ram, NULL, "pc.ram", size, perms, &error_abort);
|
||||
if (ram->ram_addr == -1)
|
||||
// out of memory
|
||||
return NULL;
|
||||
|
||||
memory_region_add_subregion(get_system_memory(uc), begin, ram);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ void error_set(Error **errp, ErrorClass err_class, const char *fmt, ...)
|
|||
err->err_class = err_class;
|
||||
|
||||
if (errp == &error_abort) {
|
||||
abort();
|
||||
// abort();
|
||||
}
|
||||
|
||||
*errp = err;
|
||||
|
@ -75,7 +75,7 @@ void error_set_errno(Error **errp, int os_errno, ErrorClass err_class,
|
|||
err->err_class = err_class;
|
||||
|
||||
if (errp == &error_abort) {
|
||||
abort();
|
||||
// abort();
|
||||
}
|
||||
|
||||
*errp = err;
|
||||
|
@ -160,7 +160,7 @@ void error_free(Error *err)
|
|||
void error_propagate(Error **dst_errp, Error *local_err)
|
||||
{
|
||||
if (local_err && dst_errp == &error_abort) {
|
||||
abort();
|
||||
// abort();
|
||||
} else if (dst_errp && !*dst_errp) {
|
||||
*dst_errp = local_err;
|
||||
} else if (local_err) {
|
||||
|
|
0
tests/regress/init.py
Normal file → Executable file
0
tests/regress/init.py
Normal file → Executable file
4
uc.c
4
uc.c
|
@ -593,7 +593,11 @@ uc_err uc_mem_map(uc_engine *uc, uint64_t address, size_t size, uint32_t perms)
|
|||
}
|
||||
uc->mapped_blocks = regions;
|
||||
}
|
||||
|
||||
uc->mapped_blocks[uc->mapped_block_count] = uc->memory_map(uc, address, size, perms);
|
||||
if (uc->mapped_blocks[uc->mapped_block_count] == NULL)
|
||||
return UC_ERR_NOMEM;
|
||||
|
||||
uc->mapped_block_count++;
|
||||
|
||||
return UC_ERR_OK;
|
||||
|
|
Loading…
Reference in a new issue