Kaydet (Commit) 8f5de14b authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: tdf#121200 better ofz#7802 infinite loop fix

Change-Id: I50163d6545782012b177a48a1aded0572499f9af
Reviewed-on: https://gerrit.libreoffice.org/63097
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst f0effa0e
...@@ -352,18 +352,34 @@ void SvxRTFParser::ReadStyleTable() ...@@ -352,18 +352,34 @@ void SvxRTFParser::ReadStyleTable()
case RTF_CHRFMT: case RTF_CHRFMT:
case RTF_BRDRDEF: case RTF_BRDRDEF:
case RTF_TABSTOPDEF: case RTF_TABSTOPDEF:
#ifndef NDEBUG
auto nEnteringToken = nToken;
#endif
auto nEnteringIndex = m_nTokenIndex;
int nSkippedTokens = 0;
if( RTF_SWGDEFS & nToken) if( RTF_SWGDEFS & nToken)
{ {
if( RTF_IGNOREFLAG != GetStackPtr( -1 )->nTokenId ) if( RTF_IGNOREFLAG != GetStackPtr( -1 )->nTokenId )
break; break;
nToken = SkipToken(); nToken = SkipToken();
++nSkippedTokens;
if( '{' == GetStackPtr( -1 )->nTokenId ) if( '{' == GetStackPtr( -1 )->nTokenId )
{ {
nToken = SkipToken(); nToken = SkipToken();
++nSkippedTokens;
} }
} }
ReadAttr( nToken, &pStyle->aAttrSet ); ReadAttr( nToken, &pStyle->aAttrSet );
if (nSkippedTokens && m_nTokenIndex == nEnteringIndex - nSkippedTokens)
{
// we called SkipToken to go back one or two, but ReadAttrs
// read nothing, so on next loop of the outer while we
// would end up in the same state again (assert that)
assert(nEnteringToken == GetNextToken());
// and loop endlessly, skip format a token
// instead to avoid that
SkipToken(nSkippedTokens);
}
break; break;
} }
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment