Skip to content

Commit

Permalink
Fix potential crash in CUILines::GetColorFromText.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel Kovalenko committed Oct 12, 2014
1 parent 1cad4a9 commit 5ee7d8b
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/xrGame/ui/UILines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,8 @@ u32 CUILines::GetColorFromText(const xr_string& str)const

begin = str.find(BEGIN);
end = str.find(END, begin);
R_ASSERT2(npos != begin, "CUISubLine::GetColorFromText -- can't find beginning tag %c[");
R_ASSERT2(npos != end, "CUISubLine::GetColorFromText -- can't find ending tag ]");

if (begin == npos || end == npos)
return m_dwTextColor;
// try default color
if (npos != str.find("%c[default]", begin, end - begin))
return m_dwTextColor;
Expand All @@ -484,11 +483,8 @@ u32 CUILines::GetColorFromText(const xr_string& str)const
comma1_pos = str.find(",", begin);
comma2_pos = str.find(",", comma1_pos + 1);
comma3_pos = str.find(",", comma2_pos + 1);

R_ASSERT2(npos != comma1_pos, "CUISubLine::GetColorFromText -- can't find first comma");
R_ASSERT2(npos != comma2_pos, "CUISubLine::GetColorFromText -- can't find second comma");
R_ASSERT2(npos != comma3_pos, "CUISubLine::GetColorFromText -- can't find third comma");

if (comma1_pos == npos || comma2_pos == npos || comma3_pos == npos)
return m_dwTextColor;

u32 a, r, g, b;
xr_string single_color;
Expand Down

0 comments on commit 5ee7d8b

Please sign in to comment.