Skip to content

Commit e590ca9

Browse files
committed
Fix a crash when console width is less than 1 char
Also use `at` vector accessor for console lines so that such bugs are trapped more cleanly.
1 parent 3a62d46 commit e590ca9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/engine/client/cl_console.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ bool Con_CheckResize()
307307
{
308308
int consoleVidWidth = cls.windowConfig.vidWidth - 2 * (consoleState.margin.sides + consoleState.padding.sides );
309309
textWidthInChars = consoleVidWidth / SCR_ConsoleFontUnicharWidth( 'W' );
310+
textWidthInChars = std::max( 1, textWidthInChars );
310311
}
311312
else
312313
{
@@ -875,7 +876,7 @@ void Con_DrawConsoleContent()
875876

876877
re.SetColor( console_color_alpha );
877878

878-
for ( const auto& token : Color::Parser( consoleState.lines[row].c_str(), console_color_alpha ) )
879+
for ( const auto& token : Color::Parser( consoleState.lines.at( row ).c_str(), console_color_alpha ) )
879880
{
880881
if ( token.Type() == Color::Token::TokenType::COLOR )
881882
{

0 commit comments

Comments
 (0)