Skip to content

Commit 5ee7d8b

Browse files
author
Pavel Kovalenko
committed
Fix potential crash in CUILines::GetColorFromText.
1 parent 1cad4a9 commit 5ee7d8b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/xrGame/ui/UILines.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -465,9 +465,8 @@ u32 CUILines::GetColorFromText(const xr_string& str)const
465465

466466
begin = str.find(BEGIN);
467467
end = str.find(END, begin);
468-
R_ASSERT2(npos != begin, "CUISubLine::GetColorFromText -- can't find beginning tag %c[");
469-
R_ASSERT2(npos != end, "CUISubLine::GetColorFromText -- can't find ending tag ]");
470-
468+
if (begin == npos || end == npos)
469+
return m_dwTextColor;
471470
// try default color
472471
if (npos != str.find("%c[default]", begin, end - begin))
473472
return m_dwTextColor;
@@ -484,11 +483,8 @@ u32 CUILines::GetColorFromText(const xr_string& str)const
484483
comma1_pos = str.find(",", begin);
485484
comma2_pos = str.find(",", comma1_pos + 1);
486485
comma3_pos = str.find(",", comma2_pos + 1);
487-
488-
R_ASSERT2(npos != comma1_pos, "CUISubLine::GetColorFromText -- can't find first comma");
489-
R_ASSERT2(npos != comma2_pos, "CUISubLine::GetColorFromText -- can't find second comma");
490-
R_ASSERT2(npos != comma3_pos, "CUISubLine::GetColorFromText -- can't find third comma");
491-
486+
if (comma1_pos == npos || comma2_pos == npos || comma3_pos == npos)
487+
return m_dwTextColor;
492488

493489
u32 a, r, g, b;
494490
xr_string single_color;

0 commit comments

Comments
 (0)