mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 00:05:36 +00:00
end address of mapping memory is not inclusive, and can wrap around to 0. fix issue #299
This commit is contained in:
parent
0e62ebc038
commit
3c72809373
6
uc.c
6
uc.c
|
@ -588,6 +588,10 @@ uc_err uc_mem_map(uc_engine *uc, uint64_t address, size_t size, uint32_t perms)
|
|||
// invalid memory mapping
|
||||
return UC_ERR_ARG;
|
||||
|
||||
// address cannot wrapp around
|
||||
if (address + size - 1 < address)
|
||||
return UC_ERR_ARG;
|
||||
|
||||
// address must be aligned to uc->target_page_size
|
||||
if ((address & uc->target_page_align) != 0)
|
||||
return UC_ERR_ARG;
|
||||
|
@ -845,7 +849,7 @@ MemoryRegion *memory_mapping(struct uc_struct* uc, uint64_t address)
|
|||
return uc->mapped_blocks[i];
|
||||
|
||||
for(i = 0; i < uc->mapped_block_count; i++) {
|
||||
if (address >= uc->mapped_blocks[i]->addr && address < uc->mapped_blocks[i]->end) {
|
||||
if (address >= uc->mapped_blocks[i]->addr && address <= uc->mapped_blocks[i]->end - 1) {
|
||||
// cache this index for the next query
|
||||
uc->mapped_block_cache_index = i;
|
||||
return uc->mapped_blocks[i];
|
||||
|
|
Loading…
Reference in a new issue