mirror of
https://github.com/CraftyBoss/SuperMarioOdysseyOnline.git
synced 2024-11-21 10:45:14 +00:00
Anims/Types: Handle out of bounds FindStr accesses without throwing
Throwing tries to call `std::__throw_out_of_range_fmt` which results in a crash. The cause of the out of bounds accesses needs to be investigated.
This commit is contained in:
parent
7e4a80b934
commit
60a5179e4b
5 changed files with 24 additions and 4 deletions
|
@ -488,6 +488,10 @@ namespace CaptureAnims {
|
|||
}
|
||||
|
||||
static constexpr const char *FindStr(Type type) {
|
||||
return s_Strs.at(ToValue(type));
|
||||
const s16 type_ = (s16)type;
|
||||
if (0 <= type_ && type_ < s_Strs.size())
|
||||
return s_Strs[type_];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -98,6 +98,10 @@ namespace CaptureTypes {
|
|||
}
|
||||
|
||||
static constexpr const char *FindStr(Type type) {
|
||||
return s_Strs.at(ToValue(type));
|
||||
const s16 type_ = (s16)type;
|
||||
if (0 <= type_ && type_ < s_Strs.size())
|
||||
return s_Strs[type_];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -1154,6 +1154,10 @@ namespace PlayerAnims {
|
|||
}
|
||||
|
||||
static constexpr const char *FindStr(Type type) {
|
||||
return s_Strs.at(ToValue(type));
|
||||
const s16 type_ = (s16)type;
|
||||
if (0 <= type_ && type_ < s_Strs.size())
|
||||
return s_Strs[type_];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -72,6 +72,10 @@ namespace WipeTypes {
|
|||
}
|
||||
|
||||
static constexpr const char *FindStr(Type type) {
|
||||
return s_Strs.at(ToValue(type));
|
||||
const s16 type_ = (s16)type;
|
||||
if (0 <= type_ && type_ < s_Strs.size())
|
||||
return s_Strs[type_];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
}
|
|
@ -783,12 +783,16 @@ void Client::updatePlayerInfo(PlayerInf *packet) {
|
|||
} else {
|
||||
strcpy(curInfo->curAnimStr, "Wait");
|
||||
}
|
||||
if (strlen(curInfo->curAnimStr) == 0)
|
||||
Logger::log("[ERROR] %s: actName was out of bounds: %d", __func__, packet->actName);
|
||||
|
||||
if(packet->subActName != PlayerAnims::Type::Unknown) {
|
||||
strcpy(curInfo->curSubAnimStr, PlayerAnims::FindStr(packet->subActName));
|
||||
} else {
|
||||
strcpy(curInfo->curSubAnimStr, "");
|
||||
}
|
||||
if (strlen(curInfo->curSubAnimStr) == 0)
|
||||
Logger::log("[ERROR] %s: subActName was out of bounds: %d", __func__, packet->subActName);
|
||||
|
||||
curInfo->curAnim = packet->actName;
|
||||
curInfo->curSubAnim = packet->subActName;
|
||||
|
|
Loading…
Reference in a new issue