[Libreoffice-commits] core.git: vcl/qa
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Thu Sep 20 07:02:54 UTC 2018
vcl/qa/cppunit/pdfexport/pdfexport.cxx | 32 ++++++++++++++------------------
1 file changed, 14 insertions(+), 18 deletions(-)
New commits:
commit a4923f1d25c5449da3547ca5846379d719cee648
Author: Miklos Vajna <vmiklos at collabora.co.uk>
AuthorDate: Wed Sep 19 13:28:51 2018 +0200
Commit: Miklos Vajna <vmiklos at collabora.co.uk>
CommitDate: Thu Sep 20 09:02:28 2018 +0200
CppunitTest_vcl_pdfexport: fix use after free
Just do the minimal fixing, a follow-up commit should clean up the
copy&paste coding that happened here in previous commits.
Change-Id: I44306e2fee57d55997414e62120c7e5037f306fb
Reviewed-on: https://gerrit.libreoffice.org/60757
Tested-by: Michael Stahl <Michael.Stahl at cib.de>
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
diff --git a/vcl/qa/cppunit/pdfexport/pdfexport.cxx b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
index cbd42a738c31..0b4892304ebc 100644
--- a/vcl/qa/cppunit/pdfexport/pdfexport.cxx
+++ b/vcl/qa/cppunit/pdfexport/pdfexport.cxx
@@ -38,6 +38,8 @@ class PdfExportTest : public test::BootstrapFixture, public unotest::MacrosTest
uno::Reference<lang::XComponent> mxComponent;
FPDF_PAGE mpPdfPage = nullptr;
FPDF_DOCUMENT mpPdfDocument = nullptr;
+ /// Underlying memory of mpPdfDocument.
+ SvMemoryStream maPdfMemory;
utl::TempFile maTempFile;
SvMemoryStream maMemory;
// Export the document as PDF, then parse it with PDFium.
@@ -287,9 +289,8 @@ void PdfExportTest::testTdf105461()
// Parse the export result with pdfium.
SvFileStream aFile(maTempFile.GetURL(), StreamMode::READ);
- SvMemoryStream aMemory;
- aMemory.WriteStream(aFile);
- mpPdfDocument = FPDF_LoadMemDocument(aMemory.GetData(), aMemory.GetSize(), /*password=*/nullptr);
+ maPdfMemory.WriteStream(aFile);
+ mpPdfDocument = FPDF_LoadMemDocument(maPdfMemory.GetData(), maPdfMemory.GetSize(), /*password=*/nullptr);
CPPUNIT_ASSERT(mpPdfDocument);
// The document has one page.
@@ -339,9 +340,8 @@ void PdfExportTest::testTdf107868()
// Parse the export result with pdfium.
SvFileStream aFile(maTempFile.GetURL(), StreamMode::READ);
- SvMemoryStream aMemory;
- aMemory.WriteStream(aFile);
- mpPdfDocument = FPDF_LoadMemDocument(aMemory.GetData(), aMemory.GetSize(), /*password=*/nullptr);
+ maPdfMemory.WriteStream(aFile);
+ mpPdfDocument = FPDF_LoadMemDocument(maPdfMemory.GetData(), maPdfMemory.GetSize(), /*password=*/nullptr);
if (!mpPdfDocument)
// Printing to PDF failed in a non-interesting way, e.g. CUPS is not
// running, there is no printer defined, etc.
@@ -769,9 +769,8 @@ void PdfExportTest::testTdf108963()
// Parse the export result with pdfium.
SvFileStream aFile(maTempFile.GetURL(), StreamMode::READ);
- SvMemoryStream aMemory;
- aMemory.WriteStream(aFile);
- mpPdfDocument = FPDF_LoadMemDocument(aMemory.GetData(), aMemory.GetSize(), /*password=*/nullptr);
+ maPdfMemory.WriteStream(aFile);
+ mpPdfDocument = FPDF_LoadMemDocument(maPdfMemory.GetData(), maPdfMemory.GetSize(), /*password=*/nullptr);
CPPUNIT_ASSERT(mpPdfDocument);
// The document has one page.
@@ -973,9 +972,8 @@ void PdfExportTest::testTdf115117_1a()
// Parse the export result with pdfium.
SvFileStream aFile(maTempFile.GetURL(), StreamMode::READ);
- SvMemoryStream aMemory;
- aMemory.WriteStream(aFile);
- mpPdfDocument = FPDF_LoadMemDocument(aMemory.GetData(), aMemory.GetSize(), /*password=*/nullptr);
+ maPdfMemory.WriteStream(aFile);
+ mpPdfDocument = FPDF_LoadMemDocument(maPdfMemory.GetData(), maPdfMemory.GetSize(), /*password=*/nullptr);
CPPUNIT_ASSERT(mpPdfDocument);
// The document has one page.
@@ -1016,9 +1014,8 @@ void PdfExportTest::testTdf115117_2a()
// Parse the export result with pdfium.
SvFileStream aFile(maTempFile.GetURL(), StreamMode::READ);
- SvMemoryStream aMemory;
- aMemory.WriteStream(aFile);
- mpPdfDocument = FPDF_LoadMemDocument(aMemory.GetData(), aMemory.GetSize(), /*password=*/nullptr);
+ maPdfMemory.WriteStream(aFile);
+ mpPdfDocument = FPDF_LoadMemDocument(maPdfMemory.GetData(), maPdfMemory.GetSize(), /*password=*/nullptr);
CPPUNIT_ASSERT(mpPdfDocument);
// The document has one page.
@@ -1327,10 +1324,9 @@ void PdfExportTest::testTdf105954()
// Parse the export result with pdfium.
SvFileStream aFile(maTempFile.GetURL(), StreamMode::READ);
- SvMemoryStream aMemory;
- aMemory.WriteStream(aFile);
+ maPdfMemory.WriteStream(aFile);
mpPdfDocument
- = FPDF_LoadMemDocument(aMemory.GetData(), aMemory.GetSize(), /*password=*/nullptr);
+ = FPDF_LoadMemDocument(maPdfMemory.GetData(), maPdfMemory.GetSize(), /*password=*/nullptr);
CPPUNIT_ASSERT(mpPdfDocument);
// The document has one page.
More information about the Libreoffice-commits
mailing list