Skip to content

Commit 51386f3

Browse files
authored
fix(displaystring): Guard null bold font pointer in W3DDisplayString::setFont() (#2893)
1 parent 4ac829f commit 51386f3

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayString.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,10 @@ void W3DDisplayString::setFont( GameFont *font )
306306
// set the font in our renderer
307307
m_textRenderer.Set_Font( static_cast<FontCharsClass *>(m_font->fontData) );
308308

309-
m_textRendererHotKey.Set_Font( static_cast<FontCharsClass *>(TheFontLibrary->getFont(font->nameString,font->pointSize, TRUE)->fontData) );
309+
if( GameFont *boldFont = TheFontLibrary->getFont( font->nameString, font->pointSize, TRUE ) )
310+
{
311+
m_textRendererHotKey.Set_Font( static_cast<FontCharsClass *>(boldFont->fontData) );
312+
}
310313
// recompute extents for text with new font
311314
computeExtents();
312315

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplayString.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,10 @@ void W3DDisplayString::setFont( GameFont *font )
306306
// set the font in our renderer
307307
m_textRenderer.Set_Font( static_cast<FontCharsClass *>(m_font->fontData) );
308308

309-
m_textRendererHotKey.Set_Font( static_cast<FontCharsClass *>(TheFontLibrary->getFont(font->nameString,font->pointSize, TRUE)->fontData) );
309+
if( GameFont *boldFont = TheFontLibrary->getFont( font->nameString, font->pointSize, TRUE ) )
310+
{
311+
m_textRendererHotKey.Set_Font( static_cast<FontCharsClass *>(boldFont->fontData) );
312+
}
310313
// recompute extents for text with new font
311314
computeExtents();
312315

0 commit comments

Comments
 (0)