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

New commits:
commit 96c6bf6d965be0324d6e27ad5e2bce38689a8bde
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Mon Oct 7 19:57:37 2024 -0400
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Oct 16 17:38:13 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 6fe0de9c0bb903ced5ccf35a774f77bf9f3526c2)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174666
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

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