comparison romdb.c @ 2402:49b7ead35482

Fix asan violation that occurs when locking on a cart with its own mapper hardware
author Michael Pavone <pavone@retrodev.com>
date Mon, 01 Jan 2024 19:50:20 -0800
parents b9cd3c64652d
children 8171409b62ef
comparison
equal deleted inserted replaced
2401:34b4ff091891 2402:49b7ead35482
467 467
468 rom_info configure_rom_heuristics(uint8_t *rom, uint32_t rom_size, memmap_chunk const *base_map, uint32_t base_chunks) 468 rom_info configure_rom_heuristics(uint8_t *rom, uint32_t rom_size, memmap_chunk const *base_map, uint32_t base_chunks)
469 { 469 {
470 rom_info info; 470 rom_info info;
471 info.mapper_type = MAPPER_NONE; 471 info.mapper_type = MAPPER_NONE;
472 info.mapper_start_index = 0;
472 info.name = get_header_name(rom); 473 info.name = get_header_name(rom);
473 info.regions = get_header_regions(rom); 474 info.regions = get_header_regions(rom);
474 info.is_save_lock_on = 0; 475 info.is_save_lock_on = 0;
475 info.rom = rom; 476 info.rom = rom;
476 info.rom_size = rom_size; 477 info.rom_size = rom_size;
832 lock_info = configure_rom(state->rom_db, state->rom + map->start, state->rom_size - map->start, NULL, 0, NULL, 0); 833 lock_info = configure_rom(state->rom_db, state->rom + map->start, state->rom_size - map->start, NULL, 0, NULL, 0);
833 } else { 834 } else {
834 //skip this entry if there is no lock on cartridge attached 835 //skip this entry if there is no lock on cartridge attached
835 return; 836 return;
836 } 837 }
838 //TODO: detect if this conflicts with host cart mapper
839 state->info->mapper_start_index = lock_info.mapper_start_index;
837 uint32_t matching_chunks = 0; 840 uint32_t matching_chunks = 0;
838 for (int i = 0; i < lock_info.map_chunks; i++) 841 for (int i = 0; i < lock_info.map_chunks; i++)
839 { 842 {
840 if (lock_info.map[i].start < 0xC00000 && lock_info.map[i].end > 0x200000) { 843 if (lock_info.map[i].start < 0xC00000 && lock_info.map[i].end > 0x200000) {
841 matching_chunks++; 844 matching_chunks++;