From cc9196c933bd4e74e3a68ba51eccd4f28e3432c9 Mon Sep 17 00:00:00 2001 From: Anuj Khare Date: Thu, 24 Jul 2014 19:47:22 +0200 Subject: [PATCH 2/4] core: Fix issue when adding annot without contents Having no content in an annotation results in a crash when generating it's appearance, since the contents pointer is dereferenced. For consistency, the same has been done in Annot::initialize. --- poppler/Annot.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/poppler/Annot.cc b/poppler/Annot.cc index fa29739..fc7b67a 100644 --- a/poppler/Annot.cc +++ b/poppler/Annot.cc @@ -1265,7 +1265,7 @@ void Annot::initialize(PDFDoc *docA, Dict *dict) { if (dict->lookup("Contents", &obj1)->isString()) { contents = obj1.getString()->copy(); } else { - contents = NULL; + contents = new GooString(); } obj1.free(); @@ -3015,6 +3015,8 @@ void AnnotFreeText::generateFreeTextAppearance() fontsize = 10; if (fontcolor == NULL) fontcolor = new AnnotColor(0, 0, 0); // Black + if (!contents) + contents = new GooString (); // Draw box GBool doFill = (color && color->getSpace() != AnnotColor::colorTransparent); -- 1.9.1