mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-07-05 17:12:14 +02:00
Truncate cheat names when they get too long instead of not parsing the cheat at all
This commit is contained in:
parent
59f86ce7fd
commit
992dd643dc
@ -321,13 +321,14 @@ bool DmntCheatManager::ParseCheats(const char *s, size_t len) {
|
||||
size_t j = i + 1;
|
||||
while (s[j] != ']') {
|
||||
j++;
|
||||
if (j >= len || (j - i - 1) >= sizeof(cur_entry->definition.readable_name)) {
|
||||
if (j >= len) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* s[i+1:j] is cheat name. */
|
||||
const size_t cheat_name_len = (j - i - 1);
|
||||
/* Truncate the cheat name if it's too long */
|
||||
const size_t cheat_name_len = std::min(j - i - 1, sizeof(cur_entry->definition.readable_name));
|
||||
memcpy(cur_entry->definition.readable_name, &s[i+1], cheat_name_len);
|
||||
cur_entry->definition.readable_name[cheat_name_len] = 0;
|
||||
|
||||
@ -346,13 +347,14 @@ bool DmntCheatManager::ParseCheats(const char *s, size_t len) {
|
||||
size_t j = i + 1;
|
||||
while (s[j] != '}') {
|
||||
j++;
|
||||
if (j >= len || (j - i - 1) >= sizeof(cur_entry->definition.readable_name)) {
|
||||
if (j >= len) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* s[i+1:j] is cheat name. */
|
||||
const size_t cheat_name_len = (j - i - 1);
|
||||
/* Truncate the master cheat name if it's too long */
|
||||
const size_t cheat_name_len = std::min(j - i - 1, sizeof(cur_entry->definition.readable_name));
|
||||
memcpy(cur_entry->definition.readable_name, &s[i+1], cheat_name_len);
|
||||
cur_entry->definition.readable_name[cheat_name_len] = 0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user