From e6fa2336dae971a02fbc3c50bcf44f5961ff6e12 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Mon, 5 Apr 2021 23:09:32 +0300 Subject: [PATCH] Fix a potential crash/corruption when modifying cheats --- Core/cheats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/cheats.c b/Core/cheats.c index 451dddbb..8defc6cb 100644 --- a/Core/cheats.c +++ b/Core/cheats.c @@ -200,7 +200,7 @@ void GB_update_cheat(GB_gameboy_t *gb, const GB_cheat_t *_cheat, const char *des GB_cheat_hash_t **hash = &gb->cheat_hash[hash_addr(cheat->address)]; for (unsigned i = 0; i < (*hash)->size; i++) { if ((*hash)->cheats[i] == cheat) { - (*hash)->cheats[i] = (*hash)->cheats[(*hash)->size--]; + (*hash)->cheats[i] = (*hash)->cheats[--(*hash)->size]; if ((*hash)->size == 0) { free(*hash); *hash = NULL;