diff --git a/Sources/Plasma/PubUtilLib/plGImage/plFont.cpp b/Sources/Plasma/PubUtilLib/plGImage/plFont.cpp index ef5a20bc..92349444 100644 --- a/Sources/Plasma/PubUtilLib/plGImage/plFont.cpp +++ b/Sources/Plasma/PubUtilLib/plGImage/plFont.cpp @@ -290,8 +290,9 @@ void plFont::IRenderString( plMipmap *mip, UInt16 x, UInt16 y, const wchar_t *st { plCharacter& ch = fCharacters[(UInt16)L' ' - fFirstChar]; if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) { - if (wctob(string[0]) != EOF) - ch = (fCharacters[(UInt16)wctob(string[0]) - fFirstChar]); + UInt16 w = wctob(string[0]); + if (w != EOF && (w - fFirstChar) <= fCharacters.Count()) + ch = (fCharacters[w - fFirstChar]); } else { ch = (fCharacters[(UInt16)string[0] - fFirstChar]); } @@ -396,8 +397,9 @@ void plFont::IRenderString( plMipmap *mip, UInt16 x, UInt16 y, const wchar_t *st // calc the first character, so adjust so we make sure we don't underflow plCharacter& ch = fCharacters[(UInt16)L' ' - fFirstChar]; if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) { - if (wctob(string[0]) != EOF) - ch = (fCharacters[(UInt16)wctob(string[0]) - fFirstChar]); + UInt16 w = wctob(string[0]); + if (w != EOF && (w - fFirstChar) <= fCharacters.Count()) + ch = (fCharacters[w - fFirstChar]); } else { ch = (fCharacters[(UInt16)string[0] - fFirstChar]); } @@ -466,8 +468,9 @@ void plFont::IRenderString( plMipmap *mip, UInt16 x, UInt16 y, const wchar_t *st // handle invalid chars discretely plCharacter* charToDraw = &(fCharacters[(UInt16)L' ' - fFirstChar]); if (fCharacters.Count() <= ((UInt16)string[i] - fFirstChar)) { - if (wctob(string[i]) != EOF) - charToDraw = &(fCharacters[(UInt16)wctob(string[i]) - fFirstChar]); + UInt16 w = wctob(string[0]); + if (w != EOF && (w - fFirstChar) <= fCharacters.Count()) + ch = (fCharacters[w - fFirstChar]); } else { charToDraw = &(fCharacters[(UInt16)string[i] - fFirstChar]); } @@ -602,8 +605,9 @@ void plFont::IRenderString( plMipmap *mip, UInt16 x, UInt16 y, const wchar_t *st plCharacter& ch = fCharacters[(UInt16)L' ' - fFirstChar]; if (fCharacters.Count() <= ((UInt16)string[0] - fFirstChar)) { - if (wctob(string[0]) != EOF) - ch = (fCharacters[(UInt16)wctob(string[0]) - fFirstChar]); + UInt16 w = wctob(string[0]); + if (w != EOF && (w - fFirstChar) <= fCharacters.Count()) + ch = (fCharacters[w - fFirstChar]); } else { ch = (fCharacters[(UInt16)string[0] - fFirstChar]); }