|
|
50092c |
--- poppler/glib/poppler-document.cc
|
|
|
50092c |
+++ poppler/glib/poppler-document.cc
|
|
|
50092c |
@@ -869,12 +869,12 @@ GTree *poppler_document_create_dests_tre
|
|
|
50092c |
// Iterate from name-dict
|
|
|
50092c |
const int nDests = catalog->numDests();
|
|
|
50092c |
for (i = 0; i < nDests; ++i) {
|
|
|
50092c |
- // The names of name-dict cannot contain \0,
|
|
|
50092c |
- // so we can use strlen().
|
|
|
50092c |
- auto name = catalog->getDestsName(i);
|
|
|
50092c |
- key = poppler_named_dest_from_bytestring(reinterpret_cast<const guint8 *>(name), strlen(name));
|
|
|
50092c |
std::unique_ptr<LinkDest> link_dest = catalog->getDestsDest(i);
|
|
|
50092c |
if (link_dest) {
|
|
|
50092c |
+ // The names of name-dict cannot contain \0,
|
|
|
50092c |
+ // so we can use strlen().
|
|
|
50092c |
+ auto name = catalog->getDestsName(i);
|
|
|
50092c |
+ key = poppler_named_dest_from_bytestring(reinterpret_cast<const guint8 *>(name), strlen(name));
|
|
|
50092c |
dest = _poppler_dest_new_goto(document, link_dest.get());
|
|
|
50092c |
g_tree_insert(tree, key, dest);
|
|
|
50092c |
}
|
|
|
50092c |
@@ -883,10 +883,10 @@ GTree *poppler_document_create_dests_tre
|
|
|
50092c |
// Iterate form name-tree
|
|
|
50092c |
const int nDestsNameTree = catalog->numDestNameTree();
|
|
|
50092c |
for (i = 0; i < nDestsNameTree; ++i) {
|
|
|
50092c |
- auto name = catalog->getDestNameTreeName(i);
|
|
|
50092c |
- key = poppler_named_dest_from_bytestring(reinterpret_cast<const guint8 *>(name->c_str()), name->getLength());
|
|
|
50092c |
std::unique_ptr<LinkDest> link_dest = catalog->getDestNameTreeDest(i);
|
|
|
50092c |
if (link_dest) {
|
|
|
50092c |
+ auto name = catalog->getDestNameTreeName(i);
|
|
|
50092c |
+ key = poppler_named_dest_from_bytestring(reinterpret_cast<const guint8 *>(name->c_str()), name->getLength());
|
|
|
50092c |
dest = _poppler_dest_new_goto(document, link_dest.get());
|
|
|
50092c |
g_tree_insert(tree, key, dest);
|
|
|
50092c |
}
|
|
|
50092c |
@@ -3405,6 +3405,7 @@ PopplerFormField *poppler_document_get_f
|
|
|
50092c |
unsigned fieldNum;
|
|
|
50092c |
FormPageWidgets *widgets;
|
|
|
50092c |
FormWidget *field;
|
|
|
50092c |
+ PopplerFormField *formField;
|
|
|
50092c |
|
|
|
50092c |
FormWidget::decodeID(id, &pageNum, &fieldNum);
|
|
|
50092c |
|
|
|
50092c |
@@ -3417,8 +3418,14 @@ PopplerFormField *poppler_document_get_f
|
|
|
50092c |
return nullptr;
|
|
|
50092c |
|
|
|
50092c |
field = widgets->getWidget(fieldNum);
|
|
|
50092c |
- if (field)
|
|
|
50092c |
- return _poppler_form_field_new(document, field);
|
|
|
50092c |
+ if (field) {
|
|
|
50092c |
+ formField = _poppler_form_field_new(document, field);
|
|
|
50092c |
+ delete widgets;
|
|
|
50092c |
+
|
|
|
50092c |
+ return formField;
|
|
|
50092c |
+ }
|
|
|
50092c |
+
|
|
|
50092c |
+ delete widgets;
|
|
|
50092c |
|
|
|
50092c |
return nullptr;
|
|
|
50092c |
}
|
|
|
50092c |
--- poppler-21.01.0/glib/poppler-page.cc
|
|
|
50092c |
+++ poppler-21.01.0/glib/poppler-page.cc
|
|
|
50092c |
@@ -1530,15 +1530,18 @@ void poppler_page_add_annot(PopplerPage
|
|
|
50092c |
* first remove cropbox of the prior page before adding cropbox of the new page later */
|
|
|
50092c |
quads = new_quads_from_offset_cropbox(crop_box, annot_markup->getQuadrilaterals(), FALSE);
|
|
|
50092c |
annot_markup->setQuadrilaterals(quads);
|
|
|
50092c |
+ delete quads;
|
|
|
50092c |
}
|
|
|
50092c |
if (page_is_rotated) {
|
|
|
50092c |
/* Quadrilateral's coords need to be saved un-rotated (same as rect coords) */
|
|
|
50092c |
quads = _page_new_quads_unrotated(page->page, annot_markup->getQuadrilaterals());
|
|
|
50092c |
annot_markup->setQuadrilaterals(quads);
|
|
|
50092c |
+ delete quads;
|
|
|
50092c |
}
|
|
|
50092c |
/* Add to annot's quadrilaterals the offset for the cropbox of the new page */
|
|
|
50092c |
quads = new_quads_from_offset_cropbox(page_crop_box, annot_markup->getQuadrilaterals(), TRUE);
|
|
|
50092c |
annot_markup->setQuadrilaterals(quads);
|
|
|
50092c |
+ delete quads;
|
|
|
50092c |
}
|
|
|
50092c |
|
|
|
50092c |
page->page->addAnnot(annot->annot);
|
|
|
50092c |
--- poppler-21.01.0/glib/poppler-structure-element.cc
|
|
|
50092c |
+++ poppler-21.01.0/glib/poppler-structure-element.cc
|
|
|
50092c |
@@ -1090,6 +1090,8 @@ static inline void convert_doubles_array
|
|
|
50092c |
for (guint i = 0; i < *n_values; i++) {
|
|
|
50092c |
doubles[i] = object->arrayGet(i).getNum();
|
|
|
50092c |
}
|
|
|
50092c |
+
|
|
|
50092c |
+ values = &doubles;
|
|
|
50092c |
}
|
|
|
50092c |
|
|
|
50092c |
static inline void convert_color(Object *object, PopplerColor *color)
|
|
|
50092c |
--- poppler-21.01.0/poppler/Form.cc
|
|
|
50092c |
+++ poppler-21.01.0/poppler/Form.cc
|
|
|
50092c |
@@ -549,6 +549,7 @@ bool FormWidgetSignature::signDocument(c
|
|
|
50092c |
GooString *fname = new GooString(saveFilename);
|
|
|
50092c |
if (doc->saveAs(fname, writeForceIncremental) != errNone) {
|
|
|
50092c |
fprintf(stderr, "signDocument: error saving to file \"%s\"\n", saveFilename);
|
|
|
50092c |
+ delete fname;
|
|
|
50092c |
return false;
|
|
|
50092c |
}
|
|
|
50092c |
|
|
|
50092c |
@@ -563,6 +564,8 @@ bool FormWidgetSignature::signDocument(c
|
|
|
50092c |
FILE *file = openFile(saveFilename, "r+b");
|
|
|
50092c |
if (!updateOffsets(file, objStart, objEnd, &sigStart, &sigEnd, &fileSize)) {
|
|
|
50092c |
fprintf(stderr, "signDocument: unable update byte range\n");
|
|
|
50092c |
+ delete fname;
|
|
|
50092c |
+ fclose(file);
|
|
|
50092c |
return false;
|
|
|
50092c |
}
|
|
|
50092c |
|
|
|
50092c |
@@ -574,15 +577,21 @@ bool FormWidgetSignature::signDocument(c
|
|
|
50092c |
// and sign it
|
|
|
50092c |
const std::unique_ptr<GooString> signature = sigHandler.signDetached(password);
|
|
|
50092c |
- if (!signature)
|
|
|
50092c |
+ if (!signature) {
|
|
|
50092c |
+ delete fname;
|
|
|
50092c |
+ fclose(file);
|
|
|
50092c |
return false;
|
|
|
50092c |
+ }
|
|
|
50092c |
|
|
|
50092c |
// write signature to saved file
|
|
|
50092c |
if (!updateSignature(file, sigStart, sigEnd, signature.get())) {
|
|
|
50092c |
fprintf(stderr, "signDocument: unable update signature\n");
|
|
|
50092c |
+ delete fname;
|
|
|
50092c |
+ fclose(file);
|
|
|
50092c |
return false;
|
|
|
50092c |
}
|
|
|
50092c |
signatureField->setSignature(*signature);
|
|
|
50092c |
|
|
|
50092c |
+ delete fname;
|
|
|
50092c |
fclose(file);
|
|
|
50092c |
|
|
|
50092c |
return true;
|
|
|
50092c |
@@ -662,22 +670,30 @@ bool FormWidgetSignature::updateOffsets(
|
|
|
50092c |
}
|
|
|
50092c |
}
|
|
|
50092c |
|
|
|
50092c |
- if (*sigStart == -1 || *sigEnd == -1)
|
|
|
50092c |
+ if (*sigStart == -1 || *sigEnd == -1) {
|
|
|
50092c |
+ free(buf);
|
|
|
50092c |
return false;
|
|
|
50092c |
+ }
|
|
|
50092c |
|
|
|
50092c |
// Search for ByteRange array and update offsets
|
|
|
50092c |
for (int i = 0; i < bufSize - 10; i++) {
|
|
|
50092c |
if (buf[i] == '/' && strncmp(&buf[i], "/ByteRange", 10) == 0) {
|
|
|
50092c |
// update range
|
|
|
50092c |
char *p = setNextOffset(&buf[i], *sigStart);
|
|
|
50092c |
- if (!p)
|
|
|
50092c |
+ if (!p) {
|
|
|
50092c |
+ free(buf);
|
|
|
50092c |
return false;
|
|
|
50092c |
+ }
|
|
|
50092c |
p = setNextOffset(p, *sigEnd);
|
|
|
50092c |
- if (!p)
|
|
|
50092c |
+ if (!p) {
|
|
|
50092c |
+ free(buf);
|
|
|
50092c |
return false;
|
|
|
50092c |
+ }
|
|
|
50092c |
p = setNextOffset(p, *fileSize - *sigEnd);
|
|
|
50092c |
- if (!p)
|
|
|
50092c |
+ if (!p) {
|
|
|
50092c |
+ free(buf);
|
|
|
50092c |
return false;
|
|
|
50092c |
+ }
|
|
|
50092c |
break;
|
|
|
50092c |
}
|
|
|
50092c |
}
|
|
|
50092c |
--- poppler-21.01.0/poppler/JBIG2Stream.cc
|
|
|
50092c |
+++ poppler-21.01.0/poppler/JBIG2Stream.cc
|
|
|
50092c |
@@ -2834,6 +2834,8 @@ JBIG2Bitmap *JBIG2Stream::readGenericBit
|
|
|
50092c |
|
|
|
50092c |
if (unlikely(!codingLine || !refLine)) {
|
|
|
50092c |
error(errSyntaxError, curStr->getPos(), "Bad width in JBIG2 generic bitmap");
|
|
|
50092c |
+ gfree(refLine);
|
|
|
50092c |
+ gfree(codingLine);
|
|
|
50092c |
delete bitmap;
|
|
|
50092c |
return nullptr;
|
|
|
50092c |
}
|
|
|
50092c |
--- poppler-21.01.0/poppler/Lexer.cc
|
|
|
50092c |
+++ poppler-21.01.0/poppler/Lexer.cc
|
|
|
50092c |
@@ -461,6 +461,7 @@ Object Lexer::getObj(int objNum)
|
|
|
50092c |
} else if (n == tokBufSize) {
|
|
|
50092c |
error(errSyntaxError, getPos(), "Warning: name token is longer than what the specification says it can be");
|
|
|
50092c |
*p = c;
|
|
|
50092c |
+ delete s;
|
|
|
50092c |
s = new GooString(tokBuf, n);
|
|
|
50092c |
} else {
|
|
|
50092c |
s->append((char)c);
|
|
|
50092c |
@@ -468,6 +468,7 @@ Object Lexer::getObj(int objNum)
|
|
|
50092c |
}
|
|
|
50092c |
if (n < tokBufSize) {
|
|
|
50092c |
*p = '\0';
|
|
|
50092c |
+ delete s;
|
|
|
50092c |
return Object(objName, tokBuf);
|
|
|
50092c |
} else {
|
|
|
50092c |
Object obj(objName, s->c_str());
|
|
|
50092c |
--- poppler/poppler/CairoOutputDev.cc
|
|
|
50092c |
+++ poppler/poppler/CairoOutputDev.cc
|
|
|
50092c |
@@ -2921,8 +2921,10 @@ void CairoOutputDev::setMimeData(GfxStat
|
|
|
50092c |
|
|
|
50092c |
// colorspace in stream dict may be different from colorspace in jpx
|
|
|
50092c |
// data
|
|
|
50092c |
- if (strKind == strJPX && colorSpace)
|
|
|
50092c |
+ if (strKind == strJPX && colorSpace) {
|
|
|
50092c |
+ delete colorSpace;
|
|
|
50092c |
return;
|
|
|
50092c |
+ }
|
|
|
50092c |
|
|
|
50092c |
// only embed mime data for gray, rgb, and cmyk colorspaces.
|
|
|
50092c |
if (colorSpace) {
|
|
|
50092c |
--- poppler/poppler/TextOutputDev.cc
|
|
|
50092c |
+++ poppler/poppler/TextOutputDev.cc
|
|
|
50092c |
@@ -20,7 +20,7 @@
|
|
|
50092c |
// Copyright (C) 2006 Jeff Muizelaar <jeff@infidigm.net>
|
|
|
50092c |
// Copyright (C) 2007, 2008, 2012, 2017 Adrian Johnson <ajohnson@redneon.com>
|
|
|
50092c |
// Copyright (C) 2008 Koji Otani <sho@bbr.jp>
|
|
|
50092c |
-// Copyright (C) 2008, 2010-2012, 2014-2020 Albert Astals Cid <aacid@kde.org>
|
|
|
50092c |
+// Copyright (C) 2008, 2010-2012, 2014-2021 Albert Astals Cid <aacid@kde.org>
|
|
|
50092c |
// Copyright (C) 2008 Pino Toscano <pino@kde.org>
|
|
|
50092c |
// Copyright (C) 2008, 2010 Hib Eris <hib@hiberis.nl>
|
|
|
50092c |
// Copyright (C) 2009 Ross Moore <ross@maths.mq.edu.au>
|
|
|
50092c |
@@ -1619,7 +1619,6 @@ TextBlock::~TextBlock()
|
|
|
50092c |
|
|
|
50092c |
void TextBlock::addWord(TextWord *word)
|
|
|
50092c |
{
|
|
|
50092c |
- pool->addWord(word);
|
|
|
50092c |
if (xMin > xMax) {
|
|
|
50092c |
xMin = word->xMin;
|
|
|
50092c |
xMax = word->xMax;
|
|
|
50092c |
@@ -1639,6 +1638,7 @@ void TextBlock::addWord(TextWord *word)
|
|
|
50092c |
yMax = word->yMax;
|
|
|
50092c |
}
|
|
|
50092c |
}
|
|
|
50092c |
+ pool->addWord(word);
|
|
|
50092c |
}
|
|
|
50092c |
|
|
|
50092c |
void TextBlock::coalesce(const UnicodeMap *uMap, double fixedPitch)
|
|
|
50092c |
@@ -3064,11 +3064,13 @@ void TextPage::coalesce(bool physLayout,
|
|
|
50092c |
word0 = pool->getPool(startBaseIdx);
|
|
|
50092c |
pool->setPool(startBaseIdx, word0->next);
|
|
|
50092c |
word0->next = nullptr;
|
|
|
50092c |
- blk = new TextBlock(this, rot);
|
|
|
50092c |
- blk->addWord(word0);
|
|
|
50092c |
|
|
|
50092c |
fontSize = word0->fontSize;
|
|
|
50092c |
minBase = maxBase = word0->base;
|
|
|
50092c |
+
|
|
|
50092c |
+ blk = new TextBlock(this, rot);
|
|
|
50092c |
+ blk->addWord(word0);
|
|
|
50092c |
+
|
|
|
50092c |
colSpace1 = minColSpacing1 * fontSize;
|
|
|
50092c |
colSpace2 = minColSpacing2 * fontSize;
|
|
|
50092c |
lineSpace = maxLineSpacingDelta * fontSize;
|
|
|
50092c |
@@ -3095,9 +3097,9 @@ void TextPage::coalesce(bool physLayout,
|
|
|
50092c |
}
|
|
|
50092c |
word1 = word1->next;
|
|
|
50092c |
word2->next = nullptr;
|
|
|
50092c |
+ newMinBase = word2->base;
|
|
|
50092c |
blk->addWord(word2);
|
|
|
50092c |
found = true;
|
|
|
50092c |
- newMinBase = word2->base;
|
|
|
50092c |
} else {
|
|
|
50092c |
word0 = word1;
|
|
|
50092c |
word1 = word1->next;
|
|
|
50092c |
@@ -3123,9 +3125,9 @@ void TextPage::coalesce(bool physLayout,
|
|
|
50092c |
}
|
|
|
50092c |
word1 = word1->next;
|
|
|
50092c |
word2->next = nullptr;
|
|
|
50092c |
+ newMaxBase = word2->base;
|
|
|
50092c |
blk->addWord(word2);
|
|
|
50092c |
found = true;
|
|
|
50092c |
- newMaxBase = word2->base;
|
|
|
50092c |
} else {
|
|
|
50092c |
word0 = word1;
|
|
|
50092c |
word1 = word1->next;
|
|
|
50092c |
@@ -3198,12 +3200,12 @@ void TextPage::coalesce(bool physLayout,
|
|
|
50092c |
}
|
|
|
50092c |
word1 = word1->next;
|
|
|
50092c |
word2->next = nullptr;
|
|
|
50092c |
- blk->addWord(word2);
|
|
|
50092c |
if (word2->base < minBase) {
|
|
|
50092c |
minBase = word2->base;
|
|
|
50092c |
} else if (word2->base > maxBase) {
|
|
|
50092c |
maxBase = word2->base;
|
|
|
50092c |
}
|
|
|
50092c |
+ blk->addWord(word2);
|
|
|
50092c |
found = true;
|
|
|
50092c |
break;
|
|
|
50092c |
} else {
|
|
|
50092c |
@@ -3246,12 +3248,12 @@ void TextPage::coalesce(bool physLayout,
|
|
|
50092c |
}
|
|
|
50092c |
word1 = word1->next;
|
|
|
50092c |
word2->next = nullptr;
|
|
|
50092c |
- blk->addWord(word2);
|
|
|
50092c |
if (word2->base < minBase) {
|
|
|
50092c |
minBase = word2->base;
|
|
|
50092c |
} else if (word2->base > maxBase) {
|
|
|
50092c |
maxBase = word2->base;
|
|
|
50092c |
}
|
|
|
50092c |
+ blk->addWord(word2);
|
|
|
50092c |
found = true;
|
|
|
50092c |
break;
|
|
|
50092c |
} else {
|
|
|
50092c |
@@ -4456,13 +4456,18 @@ class TextSelectionSizer : public TextSe
|
|
|
50092c |
{
|
|
|
50092c |
public:
|
|
|
50092c |
TextSelectionSizer(TextPage *page, double scale);
|
|
|
50092c |
- ~TextSelectionSizer() override { }
|
|
|
50092c |
+ ~TextSelectionSizer() override { delete list; }
|
|
|
50092c |
|
|
|
50092c |
void visitBlock(TextBlock *block, TextLine *begin, TextLine *end, const PDFRectangle *selection) override {};
|
|
|
50092c |
void visitLine(TextLine *line, TextWord *begin, TextWord *end, int edge_begin, int edge_end, const PDFRectangle *selection) override;
|
|
|
50092c |
void visitWord(TextWord *word, int begin, int end, const PDFRectangle *selection) override {};
|
|
|
50092c |
|
|
|
50092c |
- std::vector<PDFRectangle *> *getRegion() { return list; }
|
|
|
50092c |
+ std::vector<PDFRectangle *> *takeRegion()
|
|
|
50092c |
+ {
|
|
|
50092c |
+ auto aux = list;
|
|
|
50092c |
+ list = nullptr;
|
|
|
50092c |
+ return aux;
|
|
|
50092c |
+ }
|
|
|
50092c |
|
|
|
50092c |
private:
|
|
|
50092c |
std::vector<PDFRectangle *> *list;
|
|
|
50092c |
@@ -5063,7 +5068,7 @@ std::vector<PDFRectangle *> *TextPage::g
|
|
|
50092c |
|
|
|
50092c |
visitSelection(&sizer, selection, style);
|
|
|
50092c |
|
|
|
50092c |
- return sizer.getRegion();
|
|
|
50092c |
+ return sizer.takeRegion();
|
|
|
50092c |
}
|
|
|
50092c |
|
|
|
50092c |
GooString *TextPage::getSelectionText(const PDFRectangle *selection, SelectionStyle style)
|
|
|
50092c |
--- poppler/poppler/XRef.cc
|
|
|
50092c |
+++ poppler/poppler/XRef.cc
|
|
|
50092c |
@@ -402,6 +402,7 @@ int XRef::reserve(int newSize)
|
|
|
50092c |
|
|
|
50092c |
void *p = greallocn_checkoverflow(entries, realNewSize, sizeof(XRefEntry));
|
|
|
50092c |
if (p == nullptr) {
|
|
|
50092c |
+ entries = nullptr;
|
|
|
50092c |
return 0;
|
|
|
50092c |
}
|
|
|
50092c |
|
|
|
50092c |
@@ -835,7 +836,6 @@ bool XRef::constructXRef(bool *wasRecons
|
|
|
50092c |
int offset = 0;
|
|
|
50092c |
|
|
|
50092c |
resize(0); // free entries properly
|
|
|
50092c |
- gfree(entries);
|
|
|
50092c |
capacity = 0;
|
|
|
50092c |
size = 0;
|
|
|
50092c |
entries = nullptr;
|
|
|
50092c |
--- poppler/test/pdf-inspector.cc
|
|
|
50092c |
+++ poppler/test/pdf-inspector.cc
|
|
|
50092c |
@@ -43,6 +43,7 @@ class PdfInspector
|
|
|
50092c |
{
|
|
|
50092c |
public:
|
|
|
50092c |
PdfInspector();
|
|
|
50092c |
+ ~PdfInspector();
|
|
|
50092c |
|
|
|
50092c |
void set_file_name(const char *file_name);
|
|
|
50092c |
void load(const char *file_name);
|
|
|
50092c |
@@ -108,6 +109,11 @@ PdfInspector::PdfInspector()
|
|
|
50092c |
load(nullptr);
|
|
|
50092c |
}
|
|
|
50092c |
|
|
|
50092c |
+PdfInspector::~PdfInspector(void)
|
|
|
50092c |
+{
|
|
|
50092c |
+ delete output;
|
|
|
50092c |
+}
|
|
|
50092c |
+
|
|
|
50092c |
void PdfInspector::set_file_name(const char *file_name)
|
|
|
50092c |
{
|
|
|
50092c |
GtkWidget *widget;
|
|
|
50092c |
--- poppler/utils/HtmlOutputDev.cc
|
|
|
50092c |
+++ poppler/utils/HtmlOutputDev.cc
|
|
|
50092c |
@@ -1337,6 +1337,7 @@ void HtmlOutputDev::drawPngImage(GfxStat
|
|
|
50092c |
// TODO can we calculate the resolution of the image?
|
|
|
50092c |
if (!writer->init(f1, width, height, 72, 72)) {
|
|
|
50092c |
error(errInternal, -1, "Can't init PNG for image '{0:t}'", fName);
|
|
|
50092c |
+ delete fName;
|
|
|
50092c |
delete writer;
|
|
|
50092c |
fclose(f1);
|
|
|
50092c |
return;
|
|
|
50092c |
@@ -1378,6 +1378,7 @@ void HtmlOutputDev::drawPngImage(GfxStat
|
|
|
50092c |
|
|
|
50092c |
if (!writer->writeRow(row_pointer)) {
|
|
|
50092c |
error(errIO, -1, "Failed to write into PNG '{0:t}'", fName);
|
|
|
50092c |
+ delete fName;
|
|
|
50092c |
delete writer;
|
|
|
50092c |
delete imgStr;
|
|
|
50092c |
fclose(f1);
|
|
|
50092c |
@@ -1413,6 +1414,7 @@ void HtmlOutputDev::drawPngImage(GfxStat
|
|
|
50092c |
|
|
|
50092c |
if (!writer->writeRow(&png_row)) {
|
|
|
50092c |
error(errIO, -1, "Failed to write into PNG '{0:t}'", fName);
|
|
|
50092c |
+ delete fName;
|
|
|
50092c |
delete writer;
|
|
|
50092c |
fclose(f1);
|
|
|
50092c |
gfree(png_row);
|
|
|
50092c |
--- poppler/utils/pdftotext.cc
|
|
|
50092c |
+++ poppler/utils/pdftotext.cc
|
|
|
50092c |
@@ -329,6 +329,7 @@ int main(int argc, char *argv[])
|
|
|
50092c |
fputs("\n", f);
|
|
|
50092c |
if (f != stdout) {
|
|
|
50092c |
fclose(f);
|
|
|
50092c |
+ f = nullptr;
|
|
|
50092c |
}
|
|
|
50092c |
}
|
|
|
50092c |
}
|
|
|
50092c |
@@ -348,8 +349,9 @@ int main(int argc, char *argv[])
|
|
|
50092c |
printWordBBox(f, doc, textOut, firstPage, lastPage);
|
|
|
50092c |
}
|
|
|
50092c |
}
|
|
|
50092c |
- if (f != stdout) {
|
|
|
50092c |
+ if (f != stdout && f != nullptr) {
|
|
|
50092c |
fclose(f);
|
|
|
50092c |
+ f = nullptr;
|
|
|
50092c |
}
|
|
|
50092c |
} else {
|
|
|
50092c |
textOut = new TextOutputDev(textFileName->c_str(), physLayout, fixedPitch, rawOrder, htmlMeta, discardDiag);
|
|
|
50092c |
@@ -390,7 +392,7 @@ int main(int argc, char *argv[])
|
|
|
50092c |
fputs("\n", f);
|
|
|
50092c |
fputs("</body>\n", f);
|
|
|
50092c |
fputs("</html>\n", f);
|
|
|
50092c |
- if (f != stdout) {
|
|
|
50092c |
+ if (f != stdout && f != nullptr) {
|
|
|
50092c |
fclose(f);
|
|
|
50092c |
}
|
|
|
50092c |
}
|
|
|
50092c |
@@ -533,7 +533,9 @@ void printWordBBox(FILE *f, PDFDoc *doc,
|
|
|
50092c |
for (int i = 0; i < word_length; ++i) {
|
|
|
50092c |
word = wordlist->get(i);
|
|
|
50092c |
word->getBBox(&xMinA, &yMinA, &xMaxA, &yMaxA);
|
|
|
50092c |
- const std::string myString = myXmlTokenReplace(word->getText()->c_str());
|
|
|
50092c |
+ GooString *wordText = word->getText();
|
|
|
50092c |
+ const std::string myString = myXmlTokenReplace(wordText->c_str());
|
|
|
50092c |
+ delete wordText;
|
|
|
50092c |
fprintf(f, " <word xMin=\"%f\" yMin=\"%f\" xMax=\"%f\" yMax=\"%f\">%s</word>\n", xMinA, yMinA, xMaxA, yMaxA, myString.c_str());
|
|
|
50092c |
}
|
|
|
50092c |
fprintf(f, " </page>\n");
|