Skip to content

Commit

Permalink
Merge pull request #570 from max-m/fix-cheats
Browse files Browse the repository at this point in the history
Fix memory corruption on removal / update of cheats with the same address hash
  • Loading branch information
LIJI32 authored Oct 22, 2023
2 parents 5192e3a + 0ece951 commit aff42af
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Core/cheats.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void GB_remove_cheat(GB_gameboy_t *gb, const GB_cheat_t *cheat)
*hash = NULL;
}
else {
*hash = malloc(sizeof(GB_cheat_hash_t) + sizeof(cheat) * (*hash)->size);
*hash = realloc(*hash, sizeof(GB_cheat_hash_t) + sizeof(cheat) * (*hash)->size);
}
break;
}
Expand Down Expand Up @@ -228,7 +228,7 @@ void GB_update_cheat(GB_gameboy_t *gb, const GB_cheat_t *_cheat, const char *des
*hash = NULL;
}
else {
*hash = malloc(sizeof(GB_cheat_hash_t) + sizeof(cheat) * (*hash)->size);
*hash = realloc(*hash, sizeof(GB_cheat_hash_t) + sizeof(cheat) * (*hash)->size);
}
break;
}
Expand Down

0 comments on commit aff42af

Please sign in to comment.