mirror of https://github.com/mgba-emu/mgba.git
Core: Fix GBK string memory handling in .cht loading
This commit is contained in:
parent
bc048094b1
commit
a2072b67ba
|
@ -489,8 +489,10 @@ bool mCheatParseEZFChtFile(struct mCheatDevice* device, struct VFile* vf) {
|
|||
return false;
|
||||
}
|
||||
char* name = gbkToUtf8(&cheat[1], end - cheat - 1);
|
||||
strncpy(cheatName, name, sizeof(cheatName) - 1);
|
||||
free(name);
|
||||
if (name) {
|
||||
strncpy(cheatName, name, sizeof(cheatName) - 1);
|
||||
free(name);
|
||||
}
|
||||
cheatNameLength = strlen(cheatName);
|
||||
continue;
|
||||
}
|
||||
|
@ -501,7 +503,10 @@ bool mCheatParseEZFChtFile(struct mCheatDevice* device, struct VFile* vf) {
|
|||
}
|
||||
if (strncmp(cheat, "ON", eq - cheat) != 0) {
|
||||
char* subname = gbkToUtf8(cheat, eq - cheat);
|
||||
snprintf(&cheatName[cheatNameLength], sizeof(cheatName) - cheatNameLength - 1, ": %s", subname);
|
||||
if (subname) {
|
||||
snprintf(&cheatName[cheatNameLength], sizeof(cheatName) - cheatNameLength - 1, ": %s", subname);
|
||||
free(subname);
|
||||
}
|
||||
}
|
||||
set = device->createSet(device, cheatName);
|
||||
set->enabled = false;
|
||||
|
|
Loading…
Reference in New Issue