fix: tolower/toupper UB on signed char at 10 remaining call sites

Final sweep across mpq_manager, application, auth_screen, wmo_renderer,
character_renderer, and terrain_manager. All now use the unsigned char
cast pattern. No remaining bare ::tolower/::toupper or std::tolower(c)
calls on signed char in the codebase.
This commit is contained in:
Kelsi 2026-03-29 20:27:16 -07:00
parent 34e384e1b2
commit f02be1ffac
6 changed files with 13 additions and 11 deletions

View file

@ -1002,7 +1002,7 @@ VkTexture* CharacterRenderer::compositeTextures(const std::vector<std::string>&
int dstX = 0, dstY = 0;
int expectedW256 = 0, expectedH256 = 0; // Expected size at 256-base
std::string pathLower = layerPaths[layer];
for (auto& c : pathLower) c = std::tolower(c);
for (auto& c : pathLower) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
if (pathLower.find("faceupper") != std::string::npos) {
dstX = faceUpperRegion256.x; dstY = faceUpperRegion256.y;
@ -1220,7 +1220,7 @@ VkTexture* CharacterRenderer::compositeWithRegions(const std::string& basePath,
// WoW 256-scale atlas coordinates (from CharComponentTextureSections)
int dstX = 0, dstY = 0;
std::string pathLower = ul;
for (auto& c : pathLower) c = std::tolower(c);
for (auto& c : pathLower) c = static_cast<char>(std::tolower(static_cast<unsigned char>(c)));
// Scale factor from 256-base coordinates to actual canvas size
int coordScale = width / 256;

View file

@ -534,7 +534,7 @@ std::shared_ptr<PendingTile> TerrainManager::prepareTile(int x, int y) {
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);
}
@ -612,7 +612,7 @@ std::shared_ptr<PendingTile> TerrainManager::prepareTile(int x, int y) {
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";
}

View file

@ -773,7 +773,7 @@ bool WMORenderer::loadModel(const pipeline::WMOModel& model, uint32_t id) {
// Convert .mdx/.mdl to .m2
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";
}