Guard getTagType and isCloseTag
Add guard clauses for getTagType and isCloseTag to avoid crashing if the string is empty. CCBUG: 468448
This commit is contained in:
@@ -280,6 +280,9 @@ void TextHandler::nextTokenType()
|
|||||||
|
|
||||||
QString TextHandler::getTagType() const
|
QString TextHandler::getTagType() const
|
||||||
{
|
{
|
||||||
|
if (m_nextToken.isEmpty()) {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
const int tagTypeStart = m_nextToken[1] == u'/' ? 2 : 1;
|
const int tagTypeStart = m_nextToken[1] == u'/' ? 2 : 1;
|
||||||
const int tagTypeEnd = m_nextToken.indexOf(TextRegex::endTagType, tagTypeStart);
|
const int tagTypeEnd = m_nextToken.indexOf(TextRegex::endTagType, tagTypeStart);
|
||||||
return m_nextToken.mid(tagTypeStart, tagTypeEnd - tagTypeStart);
|
return m_nextToken.mid(tagTypeStart, tagTypeEnd - tagTypeStart);
|
||||||
@@ -287,6 +290,9 @@ QString TextHandler::getTagType() const
|
|||||||
|
|
||||||
bool TextHandler::isCloseTag() const
|
bool TextHandler::isCloseTag() const
|
||||||
{
|
{
|
||||||
|
if (m_nextToken.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return m_nextToken[1] == u'/';
|
return m_nextToken[1] == u'/';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user