poppler/Annot.cc | 1 + poppler/Annot.h | 12 ++++++------ poppler/Form.cc | 9 +++++++++ poppler/Form.h | 6 +++--- poppler/Page.cc | 4 +++- poppler/UTF.cc | 5 ++++- qt4/tests/check_links.cpp | 2 ++ qt5/src/poppler-annotation.cc | 4 +++- qt5/src/poppler-optcontent-private.h | 2 ++ qt5/src/poppler-optcontent.cc | 2 ++ qt5/tests/check_links.cpp | 2 ++ utils/JSInfo.cc | 13 ++++++++----- utils/JSInfo.h | 3 ++- utils/pdfinfo.cc | 1 + 14 files changed, 48 insertions(+), 18 deletions(-)
New commits: commit 92b8ece371254dc77e3d9a67dbd8eaff44b1db20 Author: Albert Astals Cid <[email protected]> Date: Wed Jun 1 18:39:17 2016 +0200 pdfinfo: Fix another leak Again not crucial in pdfinfo itself but nice to be clean so that if it the leak check fails is because the core is doing something bad diff --git a/poppler/Form.cc b/poppler/Form.cc index 4dd56b7..d92297d 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc @@ -518,6 +518,8 @@ FormField::FormField(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *par if (terminal) { error(errSyntaxWarning, -1, "Field can't have both Widget AND Field as kids\n"); + childObj.free(); + childRef.free(); continue; } @@ -530,6 +532,8 @@ FormField::FormField(PDFDoc *docA, Object *aobj, const Ref& aref, FormField *par error(errSyntaxWarning, -1, "Field can't have both Widget AND Field as kids\n"); obj2.free(); obj3.free(); + childObj.free(); + childRef.free(); continue; } _createWidget(&childObj, ref); @@ -680,6 +684,11 @@ void FormField::_createWidget (Object *obj, Ref aref) error(errSyntaxWarning, -1, "SubType on non-terminal field, invalid document?"); numChildren--; terminal = false; + + for (int i = 0; i < numChildren; ++i) + delete widgets[i]; + gfree (widgets); + widgets = 0; } } diff --git a/qt4/tests/check_links.cpp b/qt4/tests/check_links.cpp index b5b2dee..d4e7f03 100644 --- a/qt4/tests/check_links.cpp +++ b/qt4/tests/check_links.cpp @@ -68,6 +68,8 @@ void TestLinks::checkDests_xr01() QCOMPARE( dest.destinationName(), QString::fromLatin1("section.2") ); } + qDeleteAll(links); + delete page; delete doc; } diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc index 5457ef5..98db82b 100644 --- a/qt5/src/poppler-annotation.cc +++ b/qt5/src/poppler-annotation.cc @@ -797,8 +797,10 @@ Link* AnnotationPrivate::additionalAction( Annotation::AdditionalActionType type Link *link = 0; - if ( linkAction ) + if ( linkAction ) { link = PageData::convertLinkActionToLink( linkAction, parentDoc, QRectF() ); + delete linkAction; // TODO CHECK + } return link; } diff --git a/qt5/src/poppler-optcontent-private.h b/qt5/src/poppler-optcontent-private.h index 98eda07..8bdcc04 100644 --- a/qt5/src/poppler-optcontent-private.h +++ b/qt5/src/poppler-optcontent-private.h @@ -109,12 +109,14 @@ namespace Poppler OptContentModel *q; QMap<QString, OptContentItem*> m_optContentItems; + QVector<OptContentItem*> m_optContentHeaderItems; QList<RadioButtonGroup*> m_rbgroups; OptContentItem *m_rootNode; private: void addChild( OptContentItem *parent, OptContentItem *child); void parseOrderArray( OptContentItem *parentNode, Array *orderArray ); + }; } diff --git a/qt5/src/poppler-optcontent.cc b/qt5/src/poppler-optcontent.cc index e2fd66e..de3f95b 100644 --- a/qt5/src/poppler-optcontent.cc +++ b/qt5/src/poppler-optcontent.cc @@ -185,6 +185,7 @@ namespace Poppler OptContentModelPrivate::~OptContentModelPrivate() { qDeleteAll( m_optContentItems ); + qDeleteAll( m_optContentHeaderItems ); qDeleteAll( m_rbgroups ); delete m_rootNode; } @@ -213,6 +214,7 @@ namespace Poppler } else if ( orderItem.isString() ) { GooString *label = orderItem.getString(); OptContentItem *header = new OptContentItem ( UnicodeParsedString ( label ) ); + m_optContentHeaderItems << header; // Remember it so we can delete it later addChild( parentNode, header ); parentNode = header; lastItem = header; diff --git a/qt5/tests/check_links.cpp b/qt5/tests/check_links.cpp index 4d00272..7a39838 100644 --- a/qt5/tests/check_links.cpp +++ b/qt5/tests/check_links.cpp @@ -68,6 +68,8 @@ void TestLinks::checkDests_xr01() QCOMPARE( dest.destinationName(), QString::fromLatin1("section.2") ); } + qDeleteAll(links); + delete page; delete doc; } diff --git a/utils/JSInfo.cc b/utils/JSInfo.cc index e3205c4..71bfde9 100644 --- a/utils/JSInfo.cc +++ b/utils/JSInfo.cc @@ -5,6 +5,7 @@ // This file is licensed under the GPLv2 or later // // Copyright (C) 2013 Adrian Johnson <[email protected]> +// Copyright (C) 2016 Albert Astals Cid <[email protected]> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -47,7 +48,7 @@ void JSInfo::printJS(GooString *js) { } } -void JSInfo::scanLinkAction(LinkAction *link, const char *action) { +void JSInfo::scanLinkAction(LinkAction *link, const char *action, bool deleteLink) { if (!link) return; @@ -78,6 +79,8 @@ void JSInfo::scanLinkAction(LinkAction *link, const char *action) { } } } + if (deleteLink) + delete link; } void JSInfo::scanJS(int nPages) { @@ -134,7 +137,7 @@ void JSInfo::scan(int nPages) { for (int j = 0; j < field->getNumWidgets(); j++) { FormWidget *widget = field->getWidget(j); scanLinkAction(widget->getActivationAction(), - "Field Activated"); + "Field Activated", false); scanLinkAction(widget->getAdditionalAction(Annot::actionFieldModified), "Field Modified"); scanLinkAction(widget->getAdditionalAction(Annot::actionFormatField), @@ -171,11 +174,11 @@ void JSInfo::scan(int nPages) { for (int i = 0; i < annots->getNumAnnots(); ++i) { if (annots->getAnnot(i)->getType() == Annot::typeLink) { AnnotLink *annot = static_cast<AnnotLink *>(annots->getAnnot(i)); - scanLinkAction(annot->getAction(), "Link Annotation Activated"); + scanLinkAction(annot->getAction(), "Link Annotation Activated", false); } else if (annots->getAnnot(i)->getType() == Annot::typeScreen) { AnnotScreen *annot = static_cast<AnnotScreen *>(annots->getAnnot(i)); scanLinkAction(annot->getAction(), - "Screen Annotation Activated"); + "Screen Annotation Activated", false); scanLinkAction(annot->getAdditionalAction(Annot::actionCursorEntering), "Screen Annotation Cursor Enter"); scanLinkAction(annot->getAdditionalAction(Annot::actionCursorLeaving), @@ -200,7 +203,7 @@ void JSInfo::scan(int nPages) { } else if (annots->getAnnot(i)->getType() == Annot::typeWidget) { AnnotWidget *annot = static_cast<AnnotWidget *>(annots->getAnnot(i)); scanLinkAction(annot->getAction(), - "Widget Annotation Activated"); + "Widget Annotation Activated", false); scanLinkAction(annot->getAdditionalAction(Annot::actionCursorEntering), "Widget Annotation Cursor Enter"); scanLinkAction(annot->getAdditionalAction(Annot::actionCursorLeaving), diff --git a/utils/JSInfo.h b/utils/JSInfo.h index 19b786f..b2d7b7f 100644 --- a/utils/JSInfo.h +++ b/utils/JSInfo.h @@ -5,6 +5,7 @@ // This file is licensed under the GPLv2 or later // // Copyright (C) 2013 Adrian Johnson <[email protected]> +// Copyright (C) 2016 Albert Astals Cid <[email protected]> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -52,7 +53,7 @@ private: UnicodeMap *uniMap; void scan(int nPages); - void scanLinkAction(LinkAction *link, const char *action); + void scanLinkAction(LinkAction *link, const char *action, bool deleteLink = true); void printJS(GooString *js); }; commit 4daee8a8ce40aeb658964a5902ae104549f7af75 Author: Albert Astals Cid <[email protected]> Date: Wed Jun 1 18:37:57 2016 +0200 Fix memory leak when failing to parse thumbs or actions diff --git a/poppler/Page.cc b/poppler/Page.cc index a4af340..dca52e4 100644 --- a/poppler/Page.cc +++ b/poppler/Page.cc @@ -15,7 +15,7 @@ // // Copyright (C) 2005 Kristian Høgsberg <[email protected]> // Copyright (C) 2005 Jeff Muizelaar <[email protected]> -// Copyright (C) 2005-2013 Albert Astals Cid <[email protected]> +// Copyright (C) 2005-2013, 2016 Albert Astals Cid <[email protected]> // Copyright (C) 2006-2008 Pino Toscano <[email protected]> // Copyright (C) 2006 Nickolay V. Shmyrev <[email protected]> // Copyright (C) 2006 Scott Turner <[email protected]> @@ -325,6 +325,7 @@ Page::Page(PDFDoc *docA, int numA, Dict *pageDict, Ref pageRefA, PageAttrs *attr if (!(thumb.isStream() || thumb.isNull() || thumb.isRef())) { error(errSyntaxError, -1, "Page thumb object (page {0:d}) is wrong type ({1:s})", num, thumb.getTypeName()); + thumb.free(); thumb.initNull(); } @@ -333,6 +334,7 @@ Page::Page(PDFDoc *docA, int numA, Dict *pageDict, Ref pageRefA, PageAttrs *attr if (!(actions.isDict() || actions.isNull())) { error(errSyntaxError, -1, "Page additional action object (page {0:d}) is wrong type ({1:s})", num, actions.getTypeName()); + actions.free(); actions.initNull(); } commit bc6eb28776feaa302ad93e315798cad02c1e2a54 Author: Albert Astals Cid <[email protected]> Date: Wed Jun 1 18:36:17 2016 +0200 pdfinto: Fix memory leak It's not very critial that pdfinfo does not leak, but it's nice to have no leaks so one can run ASAN over a file and see if something is wrong or not diff --git a/utils/pdfinfo.cc b/utils/pdfinfo.cc index 18221c2..911d40b 100644 --- a/utils/pdfinfo.cc +++ b/utils/pdfinfo.cc @@ -458,6 +458,7 @@ static void printInfoString(Dict *infoDict, const char *key, const char *text, n = uMap->mapUnicode(u[i], buf, sizeof(buf)); fwrite(buf, 1, n, stdout); } + gfree(u); fputc('\n', stdout); } obj.free(); commit 66617b256acfcd98f727bf11b7d7e92bcbd16de0 Author: Albert Astals Cid <[email protected]> Date: Wed Jun 1 18:35:50 2016 +0200 Point ucs4 to null when len is 0 Makes it easier for the caller than can always just free the passed pointer diff --git a/poppler/UTF.cc b/poppler/UTF.cc index 46007b7..3b3ae35 100644 --- a/poppler/UTF.cc +++ b/poppler/UTF.cc @@ -16,6 +16,7 @@ // Copyright (C) 2008 Koji Otani <[email protected]> // Copyright (C) 2012 Adrian Johnson <[email protected]> // Copyright (C) 2012 Hib Eris <[email protected]> +// Copyright (C) 2016 Albert Astals Cid <[email protected]> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -89,8 +90,10 @@ int TextStringToUCS4(GooString *textStr, Unicode **ucs4) len = textStr->getLength(); s = textStr->getCString(); - if (len == 0) + if (len == 0) { + *ucs4 = 0; return 0; + } if (textStr->hasUnicodeMarker()) { Unicode *utf16; commit 0d70a57c7ad8a53e2462560a47b6ea5eba73d6c5 Author: Albert Astals Cid <[email protected]> Date: Wed Jun 1 18:34:32 2016 +0200 Add docu to the get*Action methods Since unfortunately their behaviour is different in what you have to do with the pointer given diff --git a/poppler/Annot.h b/poppler/Annot.h index d90c808..dfafe4f 100644 --- a/poppler/Annot.h +++ b/poppler/Annot.h @@ -21,7 +21,7 @@ // Copyright (C) 2008 Hugo Mercier <[email protected]> // Copyright (C) 2008 Pino Toscano <[email protected]> // Copyright (C) 2008 Tomas Are Haavet <[email protected]> -// Copyright (C) 2009-2011, 2013 Albert Astals Cid <[email protected]> +// Copyright (C) 2009-2011, 2013, 2016 Albert Astals Cid <[email protected]> // Copyright (C) 2012, 2013 Fabio D'Urso <[email protected]> // Copyright (C) 2012, 2015 Tobias Koenig <[email protected]> // Copyright (C) 2013 Thomas Freitag <[email protected]> @@ -847,8 +847,8 @@ class AnnotScreen: public Annot { GooString* getTitle() { return title; } AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs; } - LinkAction* getAction() { return action; } - LinkAction *getAdditionalAction(AdditionalActionsType type); + LinkAction* getAction() { return action; } // The caller should now delete the result + LinkAction *getAdditionalAction(AdditionalActionsType type); // The caller should delete the result private: void initialize(PDFDoc *docA, Dict *dict); @@ -1322,9 +1322,9 @@ public: AnnotWidgetHighlightMode getMode() { return mode; } AnnotAppearanceCharacs *getAppearCharacs() { return appearCharacs; } - LinkAction *getAction() { return action; } - LinkAction *getAdditionalAction(AdditionalActionsType type); - LinkAction *getFormAdditionalAction(FormAdditionalActionsType type); + LinkAction *getAction() { return action; } // The caller should not delete the result + LinkAction *getAdditionalAction(AdditionalActionsType type); // The caller should delete the result + LinkAction *getFormAdditionalAction(FormAdditionalActionsType type); // The caller should delete the result Dict *getParent() { return parent; } private: diff --git a/poppler/Form.h b/poppler/Form.h index b566fe0..d467b47 100644 --- a/poppler/Form.h +++ b/poppler/Form.h @@ -6,7 +6,7 @@ // // Copyright 2006 Julien Rebetez <[email protected]> // Copyright 2007, 2008, 2011 Carlos Garcia Campos <[email protected]> -// Copyright 2007-2010, 2012, 2015 Albert Astals Cid <[email protected]> +// Copyright 2007-2010, 2012, 2015, 2016 Albert Astals Cid <[email protected]> // Copyright 2010 Mark Riedesel <[email protected]> // Copyright 2011 Pino Toscano <[email protected]> // Copyright 2012 Fabio D'Urso <[email protected]> @@ -106,8 +106,8 @@ public: bool isReadOnly() const; - LinkAction *getActivationAction(); - LinkAction *getAdditionalAction(Annot::FormAdditionalActionsType type); + LinkAction *getActivationAction(); // The caller should not delete the result + LinkAction *getAdditionalAction(Annot::FormAdditionalActionsType type); // The caller should delete the result // return the unique ID corresponding to pageNum/fieldNum static int encodeID (unsigned pageNum, unsigned fieldNum); commit 3db727f9546779a8896fc30a6669751d726ab86c Author: Albert Astals Cid <[email protected]> Date: Wed Jun 1 18:32:45 2016 +0200 Fix memory leak in RichMedia parsing diff --git a/poppler/Annot.cc b/poppler/Annot.cc index 60a827f..51a80e5 100644 --- a/poppler/Annot.cc +++ b/poppler/Annot.cc @@ -7066,6 +7066,7 @@ AnnotRichMedia::Instance::Instance(Dict *dict) } else { params = NULL; } + obj1.free(); } AnnotRichMedia::Instance::~Instance()
_______________________________________________ poppler mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/poppler
