Skip to content

Commit 4dd6d5f

Browse files
committed
Merge pull request 'Fix bug 73493' (#252) from fix/bug-73493 into hotfix/v8.3.2
Reviewed-on: https://git.onlyoffice.com/ONLYOFFICE/core/pulls/252
2 parents 37a5ce4 + 89d9652 commit 4dd6d5f

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

PdfFile/SrcReader/RendererOutputDev.cpp

+18-7
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,13 @@ namespace PdfReader
474474
void RendererOutputDev::restoreState(GfxState* pGState)
475475
{
476476
RELEASEINTERFACE(m_pSoftMask);
477+
if (m_sStates.empty())
478+
{ // Несбалансированный q/Q - сломанный файл
479+
updateAll(pGState);
480+
UpdateAllClip(pGState);
481+
return;
482+
}
483+
477484
m_pSoftMask = m_sStates.back().pSoftMask;
478485
if (c_nGrRenderer == m_lRendererType)
479486
{
@@ -2168,7 +2175,7 @@ namespace PdfReader
21682175
}
21692176
void RendererOutputDev::clip(GfxState* pGState)
21702177
{
2171-
if (m_bDrawOnlyText)
2178+
if (m_bDrawOnlyText || m_sStates.empty())
21722179
return;
21732180

21742181
if (!m_sStates.back().pClip)
@@ -2179,7 +2186,7 @@ namespace PdfReader
21792186
}
21802187
void RendererOutputDev::eoClip(GfxState* pGState)
21812188
{
2182-
if (m_bDrawOnlyText)
2189+
if (m_bDrawOnlyText || m_sStates.empty())
21832190
return;
21842191

21852192
if (!m_sStates.back().pClip)
@@ -2190,7 +2197,7 @@ namespace PdfReader
21902197
}
21912198
void RendererOutputDev::clipToStrokePath(GfxState* pGState)
21922199
{
2193-
if (m_bDrawOnlyText)
2200+
if (m_bDrawOnlyText || m_sStates.empty())
21942201
return;
21952202

21962203
if (!m_sStates.back().pClip)
@@ -2244,7 +2251,7 @@ namespace PdfReader
22442251
}
22452252
void RendererOutputDev::endTextObject(GfxState* pGState)
22462253
{
2247-
if (m_sStates.back().pTextClip && 4 <= pGState->getRender())
2254+
if (!m_sStates.empty() && m_sStates.back().pTextClip && 4 <= pGState->getRender())
22482255
{
22492256
AddTextClip(pGState, &m_sStates.back());
22502257
updateFont(pGState);
@@ -2584,9 +2591,13 @@ namespace PdfReader
25842591
m_pRenderer->get_FontSize(&dTempFontSize);
25852592
m_pRenderer->get_FontStyle(&lTempFontStyle);
25862593
// tmpchange
2587-
if (!m_sStates.back().pTextClip)
2588-
m_sStates.back().pTextClip = new GfxTextClip();
2589-
m_sStates.back().pTextClip->ClipToText(wsTempFontName, wsTempFontPath, dTempFontSize, (int)lTempFontStyle, arrMatrix, wsClipText, dShiftX, /*-fabs(pFont->getFontBBox()[3]) * dTfs + */ dShiftY, 0, 0, 0);
2594+
if (!m_sStates.empty())
2595+
{
2596+
if (!m_sStates.back().pTextClip)
2597+
m_sStates.back().pTextClip = new GfxTextClip();
2598+
m_sStates.back().pTextClip->ClipToText(wsTempFontName, wsTempFontPath, dTempFontSize, (int)lTempFontStyle, arrMatrix, wsClipText, dShiftX, /*-fabs(pFont->getFontBBox()[3]) * dTfs + */ dShiftY, 0, 0, 0);
2599+
2600+
}
25902601
}
25912602

25922603
m_pRenderer->put_FontSize(dOldSize);

0 commit comments

Comments
 (0)