diff --git a/.gitignore b/.gitignore index d3470d8fa61..a29b8ebd830 100644 --- a/.gitignore +++ b/.gitignore @@ -196,6 +196,8 @@ retroarch.js retroarch.js.mem *.bc *.wasm +*.wasm.map +obj-emscripten/ # only ignore .js files in the repo root /*.js diff --git a/cheat_manager.c b/cheat_manager.c index f96d40c8daf..a855ab25b6f 100644 --- a/cheat_manager.c +++ b/cheat_manager.c @@ -122,11 +122,13 @@ void cheat_manager_apply_cheats(void) void cheat_manager_set_code(unsigned i, const char *str) { cheat_manager_t *cheat_st = &cheat_manager_state; - if (!cheat_st->cheats) + if (!cheat_st->cheats || string_is_empty(str)) return; - if (!string_is_empty(str)) - cheat_st->cheats[i].code = strdup(str); + if (cheat_st->cheats[i].code) + free(cheat_st->cheats[i].code); + + cheat_st->cheats[i].code = strdup(str); cheat_st->cheats[i].state = true; }