mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-31 19:03:54 +00:00
fix: std::tolower(char) UB on signed char at 3 call sites
std::tolower(int) has undefined behavior when passed a negative value, which signed char produces for bytes > 127. The rest of the codebase correctly casts to unsigned char first; these 3 sites were missed.
This commit is contained in:
parent
27b2322444
commit
d731e0112e
1 changed files with 3 additions and 3 deletions
|
|
@ -4838,7 +4838,7 @@ void Application::loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float
|
|||
if (basePath.size() > 4) {
|
||||
extension = basePath.substr(basePath.size() - 4);
|
||||
std::string extLower = extension;
|
||||
for (char& c : extLower) c = std::tolower(c);
|
||||
for (char& c : extLower) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||
if (extLower == ".wmo") {
|
||||
basePath = basePath.substr(0, basePath.size() - 4);
|
||||
}
|
||||
|
|
@ -4949,7 +4949,7 @@ void Application::loadOnlineWorldTerrain(uint32_t mapId, float x, float y, float
|
|||
|
||||
if (m2Path.size() > 4) {
|
||||
std::string ext = m2Path.substr(m2Path.size() - 4);
|
||||
for (char& c : ext) c = std::tolower(c);
|
||||
for (char& c : ext) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||
if (ext == ".mdx" || ext == ".mdl") {
|
||||
m2Path = m2Path.substr(0, m2Path.size() - 4) + ".m2";
|
||||
}
|
||||
|
|
@ -5789,7 +5789,7 @@ void Application::buildGameObjectDisplayLookups() {
|
|||
if (modelName.empty()) continue;
|
||||
if (modelName.size() >= 4) {
|
||||
std::string ext = modelName.substr(modelName.size() - 4);
|
||||
for (char& c : ext) c = static_cast<char>(std::tolower(c));
|
||||
for (char& c : ext) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
|
||||
if (ext == ".mdx") {
|
||||
modelName = modelName.substr(0, modelName.size() - 4) + ".m2";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue