Merge pull request #351 from NieDzejkob/symbol-off-by-one

Fix off-by-one in symbol search
This commit is contained in:
Lior Halphon 2021-02-28 15:27:50 +02:00 committed by GitHub
commit ec7d756e3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,7 +40,7 @@ const GB_bank_symbol_t *GB_map_find_symbol(GB_symbol_map_t *map, uint16_t addr)
{ {
if (!map) return NULL; if (!map) return NULL;
size_t index = GB_map_find_symbol_index(map, addr); size_t index = GB_map_find_symbol_index(map, addr);
if (index < map->n_symbols && map->symbols[index].addr != addr) { if (index >= map->n_symbols || map->symbols[index].addr != addr) {
index--; index--;
} }
if (index < map->n_symbols) { if (index < map->n_symbols) {