poppler/SOURCES/poppler-0.66.0-covscan.patch

387 lines
10 KiB
Diff

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