@@ -474,6 +474,13 @@ namespace PdfReader
474
474
void RendererOutputDev::restoreState (GfxState* pGState)
475
475
{
476
476
RELEASEINTERFACE (m_pSoftMask);
477
+ if (m_sStates.empty ())
478
+ { // Несбалансированный q/Q - сломанный файл
479
+ updateAll (pGState);
480
+ UpdateAllClip (pGState);
481
+ return ;
482
+ }
483
+
477
484
m_pSoftMask = m_sStates.back ().pSoftMask ;
478
485
if (c_nGrRenderer == m_lRendererType)
479
486
{
@@ -2168,7 +2175,7 @@ namespace PdfReader
2168
2175
}
2169
2176
void RendererOutputDev::clip (GfxState* pGState)
2170
2177
{
2171
- if (m_bDrawOnlyText)
2178
+ if (m_bDrawOnlyText || m_sStates. empty () )
2172
2179
return ;
2173
2180
2174
2181
if (!m_sStates.back ().pClip )
@@ -2179,7 +2186,7 @@ namespace PdfReader
2179
2186
}
2180
2187
void RendererOutputDev::eoClip (GfxState* pGState)
2181
2188
{
2182
- if (m_bDrawOnlyText)
2189
+ if (m_bDrawOnlyText || m_sStates. empty () )
2183
2190
return ;
2184
2191
2185
2192
if (!m_sStates.back ().pClip )
@@ -2190,7 +2197,7 @@ namespace PdfReader
2190
2197
}
2191
2198
void RendererOutputDev::clipToStrokePath (GfxState* pGState)
2192
2199
{
2193
- if (m_bDrawOnlyText)
2200
+ if (m_bDrawOnlyText || m_sStates. empty () )
2194
2201
return ;
2195
2202
2196
2203
if (!m_sStates.back ().pClip )
@@ -2244,7 +2251,7 @@ namespace PdfReader
2244
2251
}
2245
2252
void RendererOutputDev::endTextObject (GfxState* pGState)
2246
2253
{
2247
- if (m_sStates.back ().pTextClip && 4 <= pGState->getRender ())
2254
+ if (!m_sStates. empty () && m_sStates.back ().pTextClip && 4 <= pGState->getRender ())
2248
2255
{
2249
2256
AddTextClip (pGState, &m_sStates.back ());
2250
2257
updateFont (pGState);
@@ -2584,9 +2591,13 @@ namespace PdfReader
2584
2591
m_pRenderer->get_FontSize (&dTempFontSize);
2585
2592
m_pRenderer->get_FontStyle (&lTempFontStyle);
2586
2593
// 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
+ }
2590
2601
}
2591
2602
2592
2603
m_pRenderer->put_FontSize (dOldSize);
0 commit comments