summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2018-09-19 13:28:51 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2018-09-20 09:02:28 +0200
commita4923f1d25c5449da3547ca5846379d719cee648 (patch)
treec11c93b96ae41722f0634e5bff50a5b4df20ba61 /vcl
parenta1400603e3178ec937b9f5e79727d8cc83b1cdad (diff)
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@cib.de> Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/pdfexport/pdfexport.cxx32
1 files changed, 14 insertions, 18 deletions
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.