From b48bfbe424f29c7c5fe871d417b432eb32d0a36a Mon Sep 17 00:00:00 2001 From: BinBashBanana <51469593+BinBashBanana@users.noreply.github.com> Date: Mon, 20 Jan 2025 09:28:59 -0800 Subject: [PATCH] fixes --- .gitignore | 2 ++ cheat_manager.c | 8 +++++--- 2 files changed, 7 insertions(+), 3 deletions(-) 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; }