From 62401ba3c9df1f7234bd272b3e659a08f546d50c Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Tue, 8 Nov 2016 15:54:15 +0100 Subject: [PATCH] xmlsecurity PDF sign: don't crash on missing trailer This will need cross-reference stream write support, just don't crash for now. Change-Id: Id48c131b22d4ed96174693f3e96b14c273d596a8 Reviewed-on: https://gerrit.libreoffice.org/30702 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- xmlsecurity/source/pdfio/pdfdocument.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/xmlsecurity/source/pdfio/pdfdocument.cxx b/xmlsecurity/source/pdfio/pdfdocument.cxx index 0bc2f80d6798..cd52f8d0eaac 100644 --- a/xmlsecurity/source/pdfio/pdfdocument.cxx +++ b/xmlsecurity/source/pdfio/pdfdocument.cxx @@ -478,6 +478,11 @@ bool PDFDocument::Sign(const uno::Reference& xCertificat m_aEditBuffer.WriteCharPtr("\nendobj\n\n"); // Write the updated Catalog object, references nAnnotId. + if (!m_pTrailer) + { + SAL_WARN("xmlsecurity.pdfio", "PDFDocument::Sign: found no trailer"); + return false; + } auto pRoot = dynamic_cast(m_pTrailer->Lookup("Root")); if (!pRoot) {