[poppler] poppler/qt4/src: poppler-document.cc, 1.22, 1.23 poppler-private.h, 1.13, 1.14

Albert Astals Cid aacid at kemper.freedesktop.org
Wed Oct 18 11:44:01 PDT 2006


Update of /cvs/poppler/poppler/qt4/src
In directory kemper:/tmp/cvs-serv13686/qt4/src

Modified Files:
	poppler-document.cc poppler-private.h 
Log Message:
2006-10-18  Albert Astals Cid <aacid at kde.org>

       * qt4/src/poppler-document.cc:
       * qt4/src/poppler-private.h: Do not crash when opening a
       encrypted document. Do not crash when unlocking a locked
       document.



Index: poppler-document.cc
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-document.cc,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- poppler-document.cc	25 Jul 2006 18:39:57 -0000	1.22
+++ poppler-document.cc	18 Oct 2006 18:43:59 -0000	1.23
@@ -51,27 +51,21 @@
 					     new GooString(userPassword.data()));
 	Document *pdoc;
 	if (doc->doc.isOk() || doc->doc.getErrorCode() == errEncrypted) {
-	    pdoc = new Document(doc);
-	    if (doc->doc.getErrorCode() == errEncrypted)
-		pdoc->m_doc->locked = true;
-	    else
-		pdoc->m_doc->locked = false;
-	    pdoc->m_doc->m_fontInfoScanner = new FontInfoScanner(&(doc->doc));
-	    int numEmb = doc->doc.getCatalog()->numEmbeddedFiles();
-	    if (!(0 == numEmb)) {
-		// we have some embedded documents, build the list
-		for (int yalv = 0; yalv < numEmb; ++yalv) {
-		    EmbFile *ef = doc->doc.getCatalog()->embeddedFile(yalv);
-		    pdoc->m_doc->m_embeddedFiles.append(new EmbeddedFile(ef));
-		    delete ef;
+		pdoc = new Document(doc);
+		if (doc->doc.getErrorCode() == errEncrypted)
+			pdoc->m_doc->locked = true;
+		else
+		{
+			pdoc->m_doc->locked = false;
+			pdoc->m_doc->fillMembers();
 		}
-	    }
-	    return pdoc;
+		return pdoc;
 	}
 	else
-	    delete doc;
-	    return NULL;
-
+	{
+		delete doc;
+	}
+	return NULL;
     }
 
     Document::Document(DocumentData *dataA)
@@ -94,19 +88,16 @@
     {
 	if (m_doc->locked) {
 	    /* racier then it needs to be */
-	    GooString *ownerPwd = new GooString(ownerPassword.data());
-	    GooString *userPwd = new GooString(userPassword.data());
-	    DocumentData *doc2 = new DocumentData(m_doc->doc.getFileName(),
-						  ownerPwd,
-						  userPwd);
-	    delete ownerPwd;
-	    delete userPwd;
+	    DocumentData *doc2 = new DocumentData(new GooString(m_doc->doc.getFileName()),
+						  new GooString(ownerPassword.data()),
+						  new GooString(userPassword.data()));
 	    if (!doc2->doc.isOk()) {
 		delete doc2;
 	    } else {
 		delete m_doc;
 		m_doc = doc2;
 		m_doc->locked = false;
+		m_doc->fillMembers();
 	    }
 	}
 	return m_doc->locked;

Index: poppler-private.h
===================================================================
RCS file: /cvs/poppler/poppler/qt4/src/poppler-private.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- poppler-private.h	24 Aug 2006 22:32:32 -0000	1.13
+++ poppler-private.h	18 Oct 2006 18:43:59 -0000	1.14
@@ -165,6 +165,20 @@
 			m_splashOutputDev = NULL;
 		}
 	}
+	
+	void fillMembers()
+	{
+		m_fontInfoScanner = new FontInfoScanner(&doc);
+		int numEmb = doc.getCatalog()->numEmbeddedFiles();
+		if (!(0 == numEmb)) {
+			// we have some embedded documents, build the list
+			for (int yalv = 0; yalv < numEmb; ++yalv) {
+				EmbFile *ef = doc.getCatalog()->embeddedFile(yalv);
+				m_embeddedFiles.append(new EmbeddedFile(ef));
+				delete ef;
+			}
+		}
+	}
 
 	class PDFDoc doc;
 	bool locked;



More information about the poppler mailing list