Commit 4d799cdf authored by Albert Astals Cid's avatar Albert Astals Cid

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
parent 4daee8a8
......@@ -5,6 +5,7 @@
// This file is licensed under the GPLv2 or later
//
// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2016 Albert Astals Cid <aacid@kde.org>
//
// 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),
......
......@@ -5,6 +5,7 @@
// This file is licensed under the GPLv2 or later
//
// Copyright (C) 2013 Adrian Johnson <ajohnson@redneon.com>
// Copyright (C) 2016 Albert Astals Cid <aacid@kde.org>
//
// 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);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment