|
|
396e5c |
--- poppler/glib/poppler-document.cc
|
|
|
396e5c |
+++ poppler/glib/poppler-document.cc
|
|
|
396e5c |
@@ -2872,6 +2872,7 @@ poppler_document_get_form_field (Poppler
|
|
|
396e5c |
unsigned fieldNum;
|
|
|
396e5c |
FormPageWidgets *widgets;
|
|
|
396e5c |
FormWidget *field;
|
|
|
396e5c |
+ PopplerFormField *formField;
|
|
|
396e5c |
|
|
|
396e5c |
FormWidget::decodeID (id, &pageNum, &fieldNum);
|
|
|
396e5c |
|
|
|
396e5c |
@@ -2884,8 +2885,14 @@ poppler_document_get_form_field (Poppler
|
|
|
396e5c |
return nullptr;
|
|
|
396e5c |
|
|
|
396e5c |
field = widgets->getWidget (fieldNum);
|
|
|
396e5c |
- if (field)
|
|
|
396e5c |
- return _poppler_form_field_new (document, field);
|
|
|
396e5c |
+ if (field) {
|
|
|
396e5c |
+ formField = _poppler_form_field_new (document, field);
|
|
|
396e5c |
+ delete widgets;
|
|
|
396e5c |
+
|
|
|
396e5c |
+ return formField;
|
|
|
396e5c |
+ }
|
|
|
396e5c |
+
|
|
|
396e5c |
+ delete widgets;
|
|
|
396e5c |
|
|
|
396e5c |
return nullptr;
|
|
|
396e5c |
}
|
|
|
396e5c |
--- poppler/poppler/CairoOutputDev.cc
|
|
|
396e5c |
+++ poppler/poppler/CairoOutputDev.cc
|
|
|
396e5c |
@@ -3010,8 +3010,10 @@ void CairoOutputDev::setMimeData(GfxStat
|
|
|
396e5c |
|
|
|
396e5c |
// colorspace in stream dict may be different from colorspace in jpx
|
|
|
396e5c |
// data
|
|
|
396e5c |
- if (strKind == strJPX && colorSpace)
|
|
|
396e5c |
+ if (strKind == strJPX && colorSpace) {
|
|
|
396e5c |
+ delete colorSpace;
|
|
|
396e5c |
return;
|
|
|
396e5c |
+ }
|
|
|
396e5c |
|
|
|
396e5c |
// only embed mime data for gray, rgb, and cmyk colorspaces.
|
|
|
396e5c |
if (colorSpace) {
|
|
|
396e5c |
--- poppler/poppler/Link.cc
|
|
|
396e5c |
+++ poppler/poppler/Link.cc
|
|
|
396e5c |
@@ -193,6 +193,7 @@ LinkAction *LinkAction::parseAction(cons
|
|
|
396e5c |
const Ref ref = obj3Ref.getRef();
|
|
|
396e5c |
if (!seenNextActions->insert(ref.num).second) {
|
|
|
396e5c |
error(errSyntaxWarning, -1, "parseAction: Circular next actions detected in array.");
|
|
|
396e5c |
+ delete actionList;
|
|
|
396e5c |
return action;
|
|
|
396e5c |
}
|
|
|
396e5c |
}
|
|
|
396e5c |
--- poppler/poppler/SplashOutputDev.cc
|
|
|
396e5c |
+++ poppler/poppler/SplashOutputDev.cc
|
|
|
396e5c |
@@ -2207,6 +2207,8 @@ reload:
|
|
|
396e5c |
error(errSyntaxError, -1, "Couldn't create a font for '{0:s}'",
|
|
|
396e5c |
gfxFont->getName() ? gfxFont->getName()->getCString()
|
|
|
396e5c |
: "(unnamed)");
|
|
|
396e5c |
+ if (fontsrc && fontsrc->isFile)
|
|
|
396e5c |
+ fontsrc->unref();
|
|
|
396e5c |
goto err2;
|
|
|
396e5c |
}
|
|
|
396e5c |
codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);
|
|
|
396e5c |
@@ -2225,6 +2227,8 @@ reload:
|
|
|
396e5c |
break;
|
|
|
396e5c |
default:
|
|
|
396e5c |
// this shouldn't happen
|
|
|
396e5c |
+ if (fontsrc && fontsrc->isFile)
|
|
|
396e5c |
+ fontsrc->unref();
|
|
|
396e5c |
goto err2;
|
|
|
396e5c |
}
|
|
|
396e5c |
fontFile->doAdjustMatrix = doAdjustFontMatrix;
|
|
|
396e5c |
--- poppler/poppler/TextOutputDev.cc
|
|
|
396e5c |
+++ poppler/poppler/TextOutputDev.cc
|
|
|
396e5c |
@@ -1526,7 +1526,6 @@ TextBlock::~TextBlock() {
|
|
|
396e5c |
}
|
|
|
396e5c |
|
|
|
396e5c |
void TextBlock::addWord(TextWord *word) {
|
|
|
396e5c |
- pool->addWord(word);
|
|
|
396e5c |
if (xMin > xMax) {
|
|
|
396e5c |
xMin = word->xMin;
|
|
|
396e5c |
xMax = word->xMax;
|
|
|
396e5c |
@@ -1546,6 +1545,7 @@ void TextBlock::addWord(TextWord *word)
|
|
|
396e5c |
yMax = word->yMax;
|
|
|
396e5c |
}
|
|
|
396e5c |
}
|
|
|
396e5c |
+ pool->addWord(word);
|
|
|
396e5c |
}
|
|
|
396e5c |
|
|
|
396e5c |
void TextBlock::coalesce(UnicodeMap *uMap, double fixedPitch) {
|
|
|
396e5c |
@@ -2999,11 +2999,13 @@ void TextPage::coalesce(GBool physLayout
|
|
|
396e5c |
word0 = pool->getPool(startBaseIdx);
|
|
|
396e5c |
pool->setPool(startBaseIdx, word0->next);
|
|
|
396e5c |
word0->next = nullptr;
|
|
|
396e5c |
- blk = new TextBlock(this, rot);
|
|
|
396e5c |
- blk->addWord(word0);
|
|
|
396e5c |
|
|
|
396e5c |
fontSize = word0->fontSize;
|
|
|
396e5c |
minBase = maxBase = word0->base;
|
|
|
396e5c |
+
|
|
|
396e5c |
+ blk = new TextBlock(this, rot);
|
|
|
396e5c |
+ blk->addWord(word0);
|
|
|
396e5c |
+
|
|
|
396e5c |
colSpace1 = minColSpacing1 * fontSize;
|
|
|
396e5c |
colSpace2 = minColSpacing2 * fontSize;
|
|
|
396e5c |
lineSpace = maxLineSpacingDelta * fontSize;
|
|
|
396e5c |
@@ -3037,9 +3039,9 @@ void TextPage::coalesce(GBool physLayout
|
|
|
396e5c |
}
|
|
|
396e5c |
word1 = word1->next;
|
|
|
396e5c |
word2->next = nullptr;
|
|
|
396e5c |
+ newMinBase = word2->base;
|
|
|
396e5c |
blk->addWord(word2);
|
|
|
396e5c |
found = gTrue;
|
|
|
396e5c |
- newMinBase = word2->base;
|
|
|
396e5c |
} else {
|
|
|
396e5c |
word0 = word1;
|
|
|
396e5c |
word1 = word1->next;
|
|
|
396e5c |
@@ -3072,9 +3074,9 @@ void TextPage::coalesce(GBool physLayout
|
|
|
396e5c |
}
|
|
|
396e5c |
word1 = word1->next;
|
|
|
396e5c |
word2->next = nullptr;
|
|
|
396e5c |
+ newMaxBase = word2->base;
|
|
|
396e5c |
blk->addWord(word2);
|
|
|
396e5c |
found = gTrue;
|
|
|
396e5c |
- newMaxBase = word2->base;
|
|
|
396e5c |
} else {
|
|
|
396e5c |
word0 = word1;
|
|
|
396e5c |
word1 = word1->next;
|
|
|
396e5c |
@@ -3171,12 +3173,12 @@ void TextPage::coalesce(GBool physLayout
|
|
|
396e5c |
}
|
|
|
396e5c |
word1 = word1->next;
|
|
|
396e5c |
word2->next = nullptr;
|
|
|
396e5c |
- blk->addWord(word2);
|
|
|
396e5c |
if (word2->base < minBase) {
|
|
|
396e5c |
minBase = word2->base;
|
|
|
396e5c |
} else if (word2->base > maxBase) {
|
|
|
396e5c |
maxBase = word2->base;
|
|
|
396e5c |
}
|
|
|
396e5c |
+ blk->addWord(word2);
|
|
|
396e5c |
found = gTrue;
|
|
|
396e5c |
break;
|
|
|
396e5c |
} else {
|
|
|
396e5c |
@@ -3235,12 +3237,12 @@ void TextPage::coalesce(GBool physLayout
|
|
|
396e5c |
}
|
|
|
396e5c |
word1 = word1->next;
|
|
|
396e5c |
word2->next = nullptr;
|
|
|
396e5c |
- blk->addWord(word2);
|
|
|
396e5c |
if (word2->base < minBase) {
|
|
|
396e5c |
minBase = word2->base;
|
|
|
396e5c |
} else if (word2->base > maxBase) {
|
|
|
396e5c |
maxBase = word2->base;
|
|
|
396e5c |
}
|
|
|
396e5c |
+ blk->addWord(word2);
|
|
|
396e5c |
found = gTrue;
|
|
|
396e5c |
break;
|
|
|
396e5c |
} else {
|
|
|
396e5c |
@@ -4509,7 +4511,7 @@ GooList **TextSelectionDumper::takeWordL
|
|
|
396e5c |
class TextSelectionSizer : public TextSelectionVisitor {
|
|
|
396e5c |
public:
|
|
|
396e5c |
TextSelectionSizer(TextPage *page, double scale);
|
|
|
396e5c |
- ~TextSelectionSizer() { }
|
|
|
396e5c |
+ ~TextSelectionSizer();
|
|
|
396e5c |
|
|
|
396e5c |
void visitBlock (TextBlock *block,
|
|
|
396e5c |
TextLine *begin,
|
|
|
396e5c |
@@ -4526,7 +4526,7 @@ public:
|
|
|
396e5c |
void visitWord (TextWord *word, int begin, int end,
|
|
|
396e5c |
PDFRectangle *selection) override { };
|
|
|
396e5c |
|
|
|
396e5c |
- GooList *getRegion () { return list; }
|
|
|
396e5c |
+ GooList *getRegion ();
|
|
|
396e5c |
|
|
|
396e5c |
private:
|
|
|
396e5c |
GooList *list;
|
|
|
396e5c |
@@ -4538,6 +4540,11 @@ TextSelectionSizer::TextSelectionSizer(T
|
|
|
396e5c |
list = new GooList();
|
|
|
396e5c |
}
|
|
|
396e5c |
|
|
|
396e5c |
+TextSelectionSizer::~TextSelectionSizer()
|
|
|
396e5c |
+{
|
|
|
396e5c |
+ deleteGooList(list, PDFRectangle);
|
|
|
396e5c |
+}
|
|
|
396e5c |
+
|
|
|
396e5c |
void TextSelectionSizer::visitLine (TextLine *line,
|
|
|
396e5c |
TextWord *begin,
|
|
|
396e5c |
TextWord *end,
|
|
|
396e5c |
@@ -4594,6 +4594,21 @@ void TextSelectionSizer::visitLine (Text
|
|
|
396e5c |
list->append (rect);
|
|
|
396e5c |
}
|
|
|
396e5c |
|
|
|
396e5c |
+GooList *TextSelectionSizer::getRegion () {
|
|
|
396e5c |
+ GooList *recList;
|
|
|
396e5c |
+ int i;
|
|
|
396e5c |
+
|
|
|
396e5c |
+ recList = new GooList();
|
|
|
396e5c |
+
|
|
|
396e5c |
+ for (i = 0; i < list->getLength(); i++) {
|
|
|
396e5c |
+ PDFRectangle *selection_rect = (PDFRectangle *) list->get(i);
|
|
|
396e5c |
+
|
|
|
396e5c |
+ recList->append (new PDFRectangle(selection_rect->x1, selection_rect->y1, selection_rect->x2, selection_rect->y2));
|
|
|
396e5c |
+ }
|
|
|
396e5c |
+
|
|
|
396e5c |
+ return recList;
|
|
|
396e5c |
+}
|
|
|
396e5c |
+
|
|
|
396e5c |
|
|
|
396e5c |
class TextSelectionPainter : public TextSelectionVisitor {
|
|
|
396e5c |
public:
|
|
|
396e5c |
--- poppler/poppler/XRef.cc
|
|
|
396e5c |
+++ poppler/poppler/XRef.cc
|
|
|
396e5c |
@@ -456,6 +456,7 @@ int XRef::reserve(int newSize)
|
|
|
396e5c |
|
|
|
396e5c |
void *p = greallocn_checkoverflow(entries, realNewSize, sizeof(XRefEntry));
|
|
|
396e5c |
if (p == nullptr) {
|
|
|
396e5c |
+ entries = nullptr;
|
|
|
396e5c |
return 0;
|
|
|
396e5c |
}
|
|
|
396e5c |
|
|
|
396e5c |
@@ -877,7 +878,6 @@ GBool XRef::constructXRef(GBool *wasReco
|
|
|
396e5c |
int offset = 0;
|
|
|
396e5c |
|
|
|
396e5c |
resize(0); // free entries properly
|
|
|
396e5c |
- gfree(entries);
|
|
|
396e5c |
capacity = 0;
|
|
|
396e5c |
size = 0;
|
|
|
396e5c |
entries = nullptr;
|
|
|
396e5c |
--- poppler/qt5/src/ArthurOutputDev.cc
|
|
|
396e5c |
+++ poppler/qt5/src/ArthurOutputDev.cc
|
|
|
396e5c |
@@ -703,7 +703,11 @@ void ArthurOutputDev::updateFont(GfxStat
|
|
|
396e5c |
else
|
|
|
396e5c |
ff = FoFiTrueType::make(tmpBuf, tmpBufLen);
|
|
|
396e5c |
if (! ff)
|
|
|
396e5c |
+ {
|
|
|
396e5c |
+ if (fontsrc && fontsrc->isFile)
|
|
|
396e5c |
+ fontsrc->unref();
|
|
|
396e5c |
goto err2;
|
|
|
396e5c |
+ }
|
|
|
396e5c |
codeToGID = ((GfxCIDFont *)gfxFont)->getCodeToGIDMap(ff, &n);
|
|
|
396e5c |
delete ff;
|
|
|
396e5c |
}
|
|
|
396e5c |
@@ -719,6 +723,8 @@ void ArthurOutputDev::updateFont(GfxStat
|
|
|
396e5c |
break;
|
|
|
396e5c |
default:
|
|
|
396e5c |
// this shouldn't happen
|
|
|
396e5c |
+ if (fontsrc && fontsrc->isFile)
|
|
|
396e5c |
+ fontsrc->unref();
|
|
|
396e5c |
goto err2;
|
|
|
396e5c |
}
|
|
|
396e5c |
}
|
|
|
396e5c |
@@ -738,6 +744,8 @@ void ArthurOutputDev::updateFont(GfxStat
|
|
|
396e5c |
return;
|
|
|
396e5c |
|
|
|
396e5c |
err2:
|
|
|
396e5c |
+ if (fontsrc && !fontsrc->isFile)
|
|
|
396e5c |
+ fontsrc->unref();
|
|
|
396e5c |
delete id;
|
|
|
396e5c |
#endif
|
|
|
396e5c |
}
|
|
|
396e5c |
--- poppler/qt5/src/poppler-page.cc
|
|
|
396e5c |
+++ poppler/qt5/src/poppler-page.cc
|
|
|
396e5c |
@@ -782,6 +782,7 @@ QList<TextBox*> Page::textList(Rotation
|
|
|
396e5c |
|
|
|
396e5c |
if (!word_list || (shouldAbortExtractionCallback && shouldAbortExtractionCallback(closure))) {
|
|
|
396e5c |
delete output_dev;
|
|
|
396e5c |
+ delete word_list;
|
|
|
396e5c |
return output_list;
|
|
|
396e5c |
}
|
|
|
396e5c |
|
|
|
396e5c |
--- poppler/test/pdf-inspector.cc
|
|
|
396e5c |
+++ poppler/test/pdf-inspector.cc
|
|
|
396e5c |
@@ -46,6 +46,7 @@ class PdfInspector {
|
|
|
396e5c |
public:
|
|
|
396e5c |
|
|
|
396e5c |
PdfInspector(void);
|
|
|
396e5c |
+ ~PdfInspector(void);
|
|
|
396e5c |
|
|
|
396e5c |
void set_file_name (const char *file_name);
|
|
|
396e5c |
void load (const char *file_name);
|
|
|
396e5c |
@@ -136,6 +137,11 @@ PdfInspector::PdfInspector(void)
|
|
|
396e5c |
// set up initial widgets
|
|
|
396e5c |
load (nullptr);
|
|
|
396e5c |
}
|
|
|
396e5c |
+
|
|
|
396e5c |
+PdfInspector::~PdfInspector(void)
|
|
|
396e5c |
+{
|
|
|
396e5c |
+ delete output;
|
|
|
396e5c |
+}
|
|
|
396e5c |
|
|
|
396e5c |
void
|
|
|
396e5c |
PdfInspector::set_file_name(const char *file_name)
|
|
|
396e5c |
--- poppler/test/perf-test.cc
|
|
|
396e5c |
+++ poppler/test/perf-test.cc
|
|
|
396e5c |
@@ -1053,6 +1053,7 @@ static void ParseCommandLine(int argc, c
|
|
|
396e5c |
++i;
|
|
|
396e5c |
if (i == argc)
|
|
|
396e5c |
PrintUsageAndExit(argc, argv);
|
|
|
396e5c |
+ free(gOutFileName);
|
|
|
396e5c |
gOutFileName = str_dup(argv[i]);
|
|
|
396e5c |
} else if (str_ieq(arg, PREVIEW_ARG)) {
|
|
|
396e5c |
gfPreview = true;
|
|
|
396e5c |
--- poppler/utils/HtmlOutputDev.cc
|
|
|
396e5c |
+++ poppler/utils/HtmlOutputDev.cc
|
|
|
396e5c |
@@ -920,10 +920,11 @@ void HtmlPage::dumpComplex(FILE *file, i
|
|
|
396e5c |
|
|
|
396e5c |
fputs("\n", pageFile);
|
|
|
396e5c |
|
|
|
396e5c |
- if( !noframes )
|
|
|
396e5c |
- {
|
|
|
396e5c |
+ if( !noframes ){
|
|
|
396e5c |
fputs("</body>\n</html>\n",pageFile);
|
|
|
396e5c |
fclose(pageFile);
|
|
|
396e5c |
+ } else if (pageFile != nullptr && pageFile != file){
|
|
|
396e5c |
+ fclose(pageFile);
|
|
|
396e5c |
}
|
|
|
396e5c |
}
|
|
|
396e5c |
|
|
|
396e5c |
@@ -1376,6 +1377,7 @@ void HtmlOutputDev::drawPngImage(GfxStat
|
|
|
396e5c |
// TODO can we calculate the resolution of the image?
|
|
|
396e5c |
if (!writer->init(f1, width, height, 72, 72)) {
|
|
|
396e5c |
error(errInternal, -1, "Can't init PNG for image '{0:t}'", fName);
|
|
|
396e5c |
+ delete fName;
|
|
|
396e5c |
delete writer;
|
|
|
396e5c |
fclose(f1);
|
|
|
396e5c |
return;
|
|
|
396e5c |
@@ -1417,6 +1419,7 @@ void HtmlOutputDev::drawPngImage(GfxStat
|
|
|
396e5c |
|
|
|
396e5c |
if (!writer->writeRow(row_pointer)) {
|
|
|
396e5c |
error(errIO, -1, "Failed to write into PNG '{0:t}'", fName);
|
|
|
396e5c |
+ delete fName;
|
|
|
396e5c |
delete writer;
|
|
|
396e5c |
delete imgStr;
|
|
|
396e5c |
fclose(f1);
|
|
|
396e5c |
@@ -1455,6 +1458,7 @@ void HtmlOutputDev::drawPngImage(GfxStat
|
|
|
396e5c |
if (!writer->writeRow( &png_row ))
|
|
|
396e5c |
{
|
|
|
396e5c |
error(errIO, -1, "Failed to write into PNG '{0:t}'", fName);
|
|
|
396e5c |
+ delete fName;
|
|
|
396e5c |
delete writer;
|
|
|
396e5c |
fclose(f1);
|
|
|
396e5c |
gfree(png_row);
|
|
|
396e5c |
@@ -1472,6 +1476,8 @@ void HtmlOutputDev::drawPngImage(GfxStat
|
|
|
396e5c |
fclose(f1);
|
|
|
396e5c |
|
|
|
396e5c |
pages->addImage(fName, state);
|
|
|
396e5c |
+
|
|
|
396e5c |
+ delete fName;
|
|
|
396e5c |
#else
|
|
|
396e5c |
return;
|
|
|
396e5c |
#endif
|
|
|
396e5c |
@@ -1617,6 +1623,7 @@ GooString* HtmlOutputDev::getLinkDest(An
|
|
|
396e5c |
}
|
|
|
396e5c |
else
|
|
|
396e5c |
{
|
|
|
396e5c |
+ delete file;
|
|
|
396e5c |
return new GooString();
|
|
|
396e5c |
}
|
|
|
396e5c |
}
|
|
|
396e5c |
--- poppler/utils/pdftotext.cc
|
|
|
396e5c |
+++ poppler/utils/pdftotext.cc
|
|
|
396e5c |
@@ -356,6 +356,7 @@ int main(int argc, char *argv[]) {
|
|
|
396e5c |
fputs("\n", f);
|
|
|
396e5c |
if (f != stdout) {
|
|
|
396e5c |
fclose(f);
|
|
|
396e5c |
+ f = nullptr;
|
|
|
396e5c |
}
|
|
|
396e5c |
}
|
|
|
396e5c |
}
|
|
|
396e5c |
@@ -372,8 +373,9 @@ int main(int argc, char *argv[]) {
|
|
|
396e5c |
printWordBBox(f, doc, textOut, firstPage, lastPage);
|
|
|
396e5c |
}
|
|
|
396e5c |
}
|
|
|
396e5c |
- if (f != stdout) {
|
|
|
396e5c |
+ if (f != stdout && f != nullptr) {
|
|
|
396e5c |
fclose(f);
|
|
|
396e5c |
+ f = nullptr;
|
|
|
396e5c |
}
|
|
|
396e5c |
} else {
|
|
|
396e5c |
textOut = new TextOutputDev(textFileName->getCString(),
|
|
|
396e5c |
@@ -413,7 +415,7 @@ int main(int argc, char *argv[]) {
|
|
|
396e5c |
if (!bbox) fputs("\n", f);
|
|
|
396e5c |
fputs("</body>\n", f);
|
|
|
396e5c |
fputs("</html>\n", f);
|
|
|
396e5c |
- if (f != stdout) {
|
|
|
396e5c |
+ if (f != stdout && f != nullptr) {
|
|
|
396e5c |
fclose(f);
|
|
|
396e5c |
}
|
|
|
396e5c |
}
|