Skip to content

Commit

Permalink
Fix use after free (realloc) in ParseText.cpp
Browse files Browse the repository at this point in the history
Static analysis detected a use after free (realloc).  The
member variable should use the new string address, and it
is assigned the new string address after the usage.  This
looks to be a copy/paste error sometime in the past.  In
addition, follow the stated convention and null terminate
the string, just in case.
(cherry picked from commit df4aef6)

Signed-off-by: Stuart Morgan <smorgan@mythtv.org>

Fixes #11556
  • Loading branch information
garybuhrmaster authored and stuartm committed Jun 4, 2013
1 parent e60495b commit 63687f8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mythtv/libs/libmythfreemheg/ParseText.cpp
Expand Up @@ -800,12 +800,13 @@ void MHParseText::NextSym()
Error("Insufficient memory");
}

m_String = str;
m_String[0] = colourTable[i].r;
m_String[1] = colourTable[i].g;
m_String[2] = colourTable[i].b;
m_String[3] = colourTable[i].t;
m_String = str;
m_nStringLength = 4;
m_String[m_nStringLength] = 0;
return;
}
}
Expand Down

0 comments on commit 63687f8

Please sign in to comment.