vcl/source/filter/ipdf/pdfdocument.cxx |    6 ++++++
 1 file changed, 6 insertions(+)

New commits:
commit 656bf70a0ce5476628292cca45c1cd24bf3450cf
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Mon Oct 7 19:57:37 2024 -0400
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Thu Oct 17 08:40:15 2024 +0200

    PDFDocument::ReadWithPossibleFixup: clear before reading fixup
    
    Ensure that a read of the pdfdocument
    does not use info from failed previous reads.
    
    The result in the problematic documents
    was that GetCatalog failed because it was looking
    for an m_aTrailerOffset[0] from the failed read,
    and thus only empty pages were exported.
    
    I failed to create a clean-room document,
    and the single existing unit test that needs a fixup
    has the trailer at the same GetPosition,
    which replaced the m_aTrailerOffset
    instead of creating a second entry.
    
    Change-Id: I470b922323a2b2ebb6d4bbaa58c98f5cc492b750
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174652
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins
    Reviewed-by: Justin Luth <jl...@mail.com>
    (cherry picked from commit cb7a4d814644bf225127a93bbd6a114b6f19ac52)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174955
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>

diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx 
b/vcl/source/filter/ipdf/pdfdocument.cxx
index b5fbc757da57..f63853f86835 100644
--- a/vcl/source/filter/ipdf/pdfdocument.cxx
+++ b/vcl/source/filter/ipdf/pdfdocument.cxx
@@ -1382,6 +1382,12 @@ bool PDFDocument::Read(SvStream& rStream)
     rStream.Seek(0);
     m_aEditBuffer.WriteStream(rStream);
 
+    // clear out key items that may have been filled with info from any 
previous read attempt
+    m_aOffsetTrailers.clear();
+    m_aTrailerOffsets.clear();
+    m_pTrailer = nullptr;
+    m_pXRefStream = nullptr;
+
     // Look up the offset of the xref table.
     size_t nStartXRef = FindStartXRef(rStream);
     SAL_INFO("vcl.filter", "PDFDocument::Read: nStartXRef is " << nStartXRef);

Reply via email to