mirror of
https://github.com/JakubMelka/PDF4QT.git
synced 2025-06-05 21:59:17 +02:00
Fixed infinite loop in content stream processor
This commit is contained in:
@ -456,9 +456,14 @@ void PDFPageContentProcessor::processContent(const QByteArray& content)
|
|||||||
|
|
||||||
while (!parser.isAtEnd())
|
while (!parser.isAtEnd())
|
||||||
{
|
{
|
||||||
|
bool tokenFetched = false;
|
||||||
|
PDFInteger oldParserPosition = parser.pos();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PDFLexicalAnalyzer::Token token = parser.fetch();
|
PDFLexicalAnalyzer::Token token = parser.fetch();
|
||||||
|
tokenFetched = true;
|
||||||
|
|
||||||
switch (token.type)
|
switch (token.type)
|
||||||
{
|
{
|
||||||
case PDFLexicalAnalyzer::TokenType::Command:
|
case PDFLexicalAnalyzer::TokenType::Command:
|
||||||
@ -603,6 +608,13 @@ void PDFPageContentProcessor::processContent(const QByteArray& content)
|
|||||||
}
|
}
|
||||||
catch (PDFException exception)
|
catch (PDFException exception)
|
||||||
{
|
{
|
||||||
|
// If we get exception when parsing, and parser position is not advanced,
|
||||||
|
// then we must advance it manually, otherwise we get infinite loop.
|
||||||
|
if (!tokenFetched && oldParserPosition == parser.pos() && !parser.isAtEnd())
|
||||||
|
{
|
||||||
|
parser.seek(parser.pos() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
m_operands.clear();
|
m_operands.clear();
|
||||||
m_errorList.append(PDFRenderError(RenderErrorType::Error, exception.getMessage()));
|
m_errorList.append(PDFRenderError(RenderErrorType::Error, exception.getMessage()));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user