diff options
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/filter/ipdf/pdfdocument.cxx | 12 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 12 |
2 files changed, 18 insertions, 6 deletions
diff --git a/vcl/source/filter/ipdf/pdfdocument.cxx b/vcl/source/filter/ipdf/pdfdocument.cxx index dd1355d924a8..64cf9dc4ef90 100644 --- a/vcl/source/filter/ipdf/pdfdocument.cxx +++ b/vcl/source/filter/ipdf/pdfdocument.cxx @@ -1327,12 +1327,18 @@ bool PDFDocument::Tokenize(SvStream& rStream, TokenizeMode eMode, } else { - if (!rtl::isAsciiWhiteSpace(static_cast<unsigned char>(ch))) + auto uChar = static_cast<unsigned char>(ch); + // Be more lenient and allow unexpected null char + if (!rtl::isAsciiWhiteSpace(uChar) && uChar != 0) { - SAL_WARN("vcl.filter", "PDFDocument::Tokenize: unexpected character: " - << ch << " at byte position " << rStream.Tell()); + SAL_WARN("vcl.filter", + "PDFDocument::Tokenize: unexpected character with code " + << sal_Int32(ch) << " at byte position " << rStream.Tell()); return false; } + SAL_WARN_IF(uChar == 0, "vcl.filter", + "PDFDocument::Tokenize: unexpected null character at " + << rStream.Tell() << " - ignoring"); } break; } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index 2aa973e567c5..cfc8ffeffedc 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -8686,10 +8686,16 @@ void PDFWriterImpl::writeReferenceXObject(ReferenceXObjectEmit& rEmit) // object. if (rEmit.m_nExternalPDFDataIndex < 0) return; - auto & rExternalPDFStream = m_aExternalPDFStreams.get(rEmit.m_nExternalPDFDataIndex); - auto & rPDFDocument = rExternalPDFStream.getPDFDocument(); + auto& rExternalPDFStream = m_aExternalPDFStreams.get(rEmit.m_nExternalPDFDataIndex); + auto& pPDFDocument = rExternalPDFStream.getPDFDocument(); + if (!pPDFDocument) + { + // Couldn't parse the document and can't continue + SAL_WARN("vcl.pdfwriter", "PDFWriterImpl::writeReferenceXObject: failed to parse the document"); + return; + } - std::vector<filter::PDFObjectElement*> aPages = rPDFDocument.GetPages(); + std::vector<filter::PDFObjectElement*> aPages = pPDFDocument->GetPages(); if (aPages.empty()) { SAL_WARN("vcl.pdfwriter", "PDFWriterImpl::writeReferenceXObject: no pages"); |