From 58797681e6387b0bbbf62baeeae028188276afcc Mon Sep 17 00:00:00 2001 From: Jakub Kucharski Date: Mon, 1 Aug 2016 01:10:18 +0200 Subject: [PATCH] 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. --- poppler/XRef.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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); -- 2.9.2