diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2023-10-31 20:43:52 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2023-10-31 21:11:34 +0100 |
commit | ba26d5f5e0529d7accf6f268559b8d659ba7c6c2 (patch) | |
tree | 49e10eccd72bfe6460b99f627e05b8c0bbb42cb1 /sdext | |
parent | f2ae8b934aaac7c444e8493ed5e8189c6ce63328 (diff) |
tdf#106057: Don't fail PDFReader::read, when several entries in stack
It may happen in case of several trailers, which is OK. The calling code
will check the type of the returned object anyway.
Change-Id: I17b2f4b7cf0e0640f949565291ee5a905ef2411e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158737
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'sdext')
-rw-r--r-- | sdext/source/pdfimport/pdfparse/pdfparse.cxx | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/sdext/source/pdfimport/pdfparse/pdfparse.cxx b/sdext/source/pdfimport/pdfparse/pdfparse.cxx index baa322c1aa3c..cdd3ac13ff35 100644 --- a/sdext/source/pdfimport/pdfparse/pdfparse.cxx +++ b/sdext/source/pdfimport/pdfparse/pdfparse.cxx @@ -601,21 +601,26 @@ std::unique_ptr<PDFEntry> PDFReader::read( const char* pFileName ) pRet.reset(aGrammar.m_aObjectStack.back()); aGrammar.m_aObjectStack.pop_back(); } -#if OSL_DEBUG_LEVEL > 0 else if( nEntries > 1 ) { + // It is possible that there are multiple trailers, which is OK. + // But still keep the warnings, just in case. SAL_WARN("sdext.pdfimport.pdfparse", "error got " << nEntries << " stack objects in parse"); - for( unsigned int i = 0; i < nEntries; i++ ) + for (;;) { - SAL_WARN("sdext.pdfimport.pdfparse", typeid(*aGrammar.m_aObjectStack[i]).name()); - PDFObject* pObj = dynamic_cast<PDFObject*>(aGrammar.m_aObjectStack[i]); + PDFEntry* pEntry = aGrammar.m_aObjectStack.back(); + aGrammar.m_aObjectStack.pop_back(); + SAL_WARN("sdext.pdfimport.pdfparse", typeid(*pEntry).name()); + PDFObject* pObj = dynamic_cast<PDFObject*>(pEntry); if( pObj ) SAL_WARN("sdext.pdfimport.pdfparse", " -> object " << pObj->m_nNumber << " generation " << pObj->m_nGeneration); - else - SAL_WARN("sdext.pdfimport.pdfparse", "(type " << typeid(*aGrammar.m_aObjectStack[i]).name() << ")"); + if (aGrammar.m_aObjectStack.empty()) + { + pRet.reset(pEntry); // The first entry references all others - see PDFGrammar dtor + break; + } } } -#endif return pRet; } |