notaz.gp2x.de
/
pcsx_rearmed.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e9183d9
)
libretro: allow unlimited cheat length
author
notaz
<notasas@gmail.com>
Sun, 10 Sep 2023 19:06:56 +0000
(22:06 +0300)
committer
notaz
<notasas@gmail.com>
Sun, 10 Sep 2023 22:31:36 +0000
(
01:31
+0300)
notaz/pcsx_rearmed#306
frontend/libretro.c
patch
|
blob
|
blame
|
history
diff --git
a/frontend/libretro.c
b/frontend/libretro.c
index
b1af9f1
..
f275ca3
100644
(file)
--- a/
frontend/libretro.c
+++ b/
frontend/libretro.c
@@
-991,12
+991,13
@@
void retro_cheat_reset(void)
void retro_cheat_set(unsigned index, bool enabled, const char *code)
{
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;
//Prepare buffered cheat for PCSX's AddCheat fucntion.
int cursor = 0;
@@
-1022,10
+1023,12
@@
void retro_cheat_set(unsigned index, bool enabled, const char *code)
else
ret = AddCheat("", buf);
else
ret = AddCheat("", buf);
+finish:
if (ret != 0)
SysPrintf("Failed to set cheat %#u\n", index);
else if (index < NumCheats)
Cheats[index].Enabled = enabled;
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?
}
// just in case, maybe a win-rt port in the future?