X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=frontend%2Flibretro.c;h=4fe8637624ce75fba6fa929c9b6b085abea56a07;hb=15fdca99d6bb8e2d3346d468af163973218f0391;hp=b64c3caecec9115a3c9c2398da84e2c74e00bafd;hpb=1b591888c4aec568da64ea2897e9ad8bbf33cea1;p=pcsx_rearmed.git diff --git a/frontend/libretro.c b/frontend/libretro.c index b64c3cae..4fe86376 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -995,12 +995,13 @@ void retro_cheat_reset(void) void retro_cheat_set(unsigned index, bool enabled, const char *code) { - char buf[256]; - int ret; + int ret = -1; + char *buf; - // cheat funcs are destructive, need a copy.. - strncpy(buf, code, sizeof(buf)); - buf[sizeof(buf) - 1] = 0; + // cheat funcs are destructive, need a copy... + buf = strdup(code); + if (buf == NULL) + goto finish; //Prepare buffered cheat for PCSX's AddCheat fucntion. int cursor = 0; @@ -1026,10 +1027,12 @@ void retro_cheat_set(unsigned index, bool enabled, const char *code) else ret = AddCheat("", buf); +finish: if (ret != 0) SysPrintf("Failed to set cheat %#u\n", index); else if (index < NumCheats) Cheats[index].Enabled = enabled; + free(buf); } // just in case, maybe a win-rt port in the future?