poppler/PDFDoc.cc |    3 +++
 poppler/XRef.cc   |    6 +++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

New commits:
commit 0889366a5872316919dbb640b6cc5cda85295169
Author: Jakub Kucharski <[email protected]>
Date:   Mon Aug 1 01:10:18 2016 +0200

    XRef::createDocInfoIfNoneExists(): don't presume that DocInfo is a 
dictionary
    
    In case a PDF document doesn't comply with the PDF reference and its DocInfo
    object isn't a dictionary, remove it and create a dictionary in its place.

diff --git a/poppler/XRef.cc b/poppler/XRef.cc
index f88c632..75fa52d 100644
--- a/poppler/XRef.cc
+++ b/poppler/XRef.cc
@@ -1295,8 +1295,12 @@ Object *XRef::getDocInfoNF(Object *obj) {
 Object *XRef::createDocInfoIfNoneExists(Object *obj) {
   getDocInfo(obj);
 
-  if (!obj->isNull()) {
+  if (obj->isDict()) {
     return obj;
+  } else if (!obj->isNull()) {
+    // DocInfo exists, but isn't a dictionary (doesn't comply with the PDF 
reference)
+    obj->free();
+    removeDocInfo();
   }
 
   obj->initDict(this);
commit 7ba975630e12a3242d73372a685e016101c5e479
Author: Jakub Kucharski <[email protected]>
Date:   Mon Aug 1 01:17:08 2016 +0200

    PDFDoc::setDocInfoStringEntry(): free empty value string
    
    Normally the ownership of value is passed on to the Object class. In case 
value
    is an empty string, it doesn't happen, so we have to free it in order to 
have
    a uniform behaviour managing memory and not to introduce memory leaks.

diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc
index a51d8b6..f3383fc 100644
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -612,6 +612,9 @@ void PDFDoc::setDocInfoModified(Object *infoObj)
 void PDFDoc::setDocInfoStringEntry(const char *key, GooString *value)
 {
   GBool removeEntry = !value || value->getLength() == 0;
+  if (removeEntry) {
+    delete value;
+  }
 
   Object infoObj;
   getDocInfo(&infoObj);
_______________________________________________
poppler mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to