Hello again Dom!

I have found what I think is a bug in the way that PdfInfo returns its String entries. The function in question is PdfInfo::GetStringFromInfoDict() which ensures that the PdfObject its returning is in fact a string before calling GetString() on that object. If the PdfObject is of any other type the function returns NULL.

return pObj && pObj->IsString() ? pObj->GetString() : PdfString::StringNull;

However if pObj is a Hex String, the function incorrectly returns StringNull, even though (as I understand it) calling GetString() on a hex string is perfectly safe and allowable.

All that we need to do here is add a second test for the case where pObj is a Hex string:

return pObj && (pObj->IsString() || pObj->IsHexString()) ? pObj->GetString() : PdfString::StringNull;

I have attached a patch for this bug.
Cheers!
~Michael Marsella


Index: PdfInfo.cpp
===================================================================
--- PdfInfo.cpp (revision 1232)
+++ PdfInfo.cpp (working copy)
@@ -72,7 +72,7 @@
 {
     PdfObject* pObj = m_pObject->GetDictionary().GetKey( rName );
     
-    return pObj && pObj->IsString() ? pObj->GetString() : 
PdfString::StringNull;
+    return pObj && (pObj->IsString() || pObj->IsHexString()) ? 
pObj->GetString() : PdfString::StringNull;
 }
 
 const PdfName & PdfInfo::GetNameFromInfoDict(const PdfName & rName) const
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to