summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2014-11-03 19:20:23 +0100
committerAlbert Astals Cid <aacid@kde.org>2014-11-03 19:20:23 +0100
commit2fd0cd652cfc03c9af35a59192729e4ed26e8146 (patch)
treeeccb310ff40b28e17c31ad43255c547c5182b800 /utils
parentd6ea8acbb348fdb43601a963ba5407e933565003 (diff)
Fix memory leaks when running pdfseparate
Bug #84768
Diffstat (limited to 'utils')
-rw-r--r--utils/pdfseparate.cc8
-rw-r--r--utils/pdfunite.cc4
2 files changed, 8 insertions, 4 deletions
diff --git a/utils/pdfseparate.cc b/utils/pdfseparate.cc
index 31dc18ce..bc98c7d1 100644
--- a/utils/pdfseparate.cc
+++ b/utils/pdfseparate.cc
@@ -54,6 +54,7 @@ bool extractPages (const char *srcFileName, const char *destFileName) {
if (!doc->isOk()) {
error(errSyntaxError, -1, "Could not extract page(s) from damaged file ('{0:s}')", srcFileName);
+ delete doc;
return false;
}
@@ -74,6 +75,7 @@ bool extractPages (const char *srcFileName, const char *destFileName) {
error(errCommandLine, -1,
"Wrong page range given: the first page ({0:d}) can not be after the last page ({1:d}).",
firstPage, lastPage);
+ delete doc;
return false;
}
bool foundmatch = false;
@@ -97,6 +99,7 @@ bool extractPages (const char *srcFileName, const char *destFileName) {
if (!foundmatch && firstPage != lastPage) {
error(errSyntaxError, -1, "'{0:s}' must contain '%%d' if more than one page should be extracted", destFileName);
free(auxDestFileName);
+ delete doc;
return false;
}
@@ -113,6 +116,7 @@ bool extractPages (const char *srcFileName, const char *destFileName) {
if (p != NULL) {
error(errSyntaxError, -1, "'{0:s}' can only contain one '%d' pattern", destFileName);
free(auxDestFileName);
+ delete doc;
return false;
}
free(auxDestFileName);
@@ -123,12 +127,12 @@ bool extractPages (const char *srcFileName, const char *destFileName) {
int errCode = doc->savePageAs(gpageName, pageNo);
if ( errCode != errNone) {
delete gpageName;
- delete gfileName;
+ delete doc;
return false;
}
delete gpageName;
}
- delete gfileName;
+ delete doc;
return true;
}
diff --git a/utils/pdfunite.cc b/utils/pdfunite.cc
index 787b1f07..05a05603 100644
--- a/utils/pdfunite.cc
+++ b/utils/pdfunite.cc
@@ -7,7 +7,7 @@
// Copyright (C) 2011-2014 Thomas Freitag <Thomas.Freitag@alfa.de>
// Copyright (C) 2012 Arseny Solokha <asolokha@gmx.com>
// Copyright (C) 2012 Fabio D'Urso <fabiodurso@hotmail.it>
-// Copyright (C) 2012 Albert Astals Cid <aacid@kde.org>
+// Copyright (C) 2012, 2014 Albert Astals Cid <aacid@kde.org>
// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2013 Hib Eris <hib@hiberis.nl>
//
@@ -116,7 +116,7 @@ int main (int argc, char *argv[])
cropBox = docs[i]->getCatalog()->getPage(j)->getCropBox();
docs[i]->replacePageDict(j,
docs[i]->getCatalog()->getPage(j)->getRotate(),
- docs[i]->getCatalog()->getPage(j)->getMediaBox(), cropBox, NULL);
+ docs[i]->getCatalog()->getPage(j)->getMediaBox(), cropBox);
Ref *refPage = docs[i]->getCatalog()->getPageRef(j);
Object page;
docs[i]->getXRef()->fetch(refPage->num, refPage->gen, &page);