[poppler] poppler/GfxState.cc qt5/src

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jan 1 23:15:11 UTC 2019


 poppler/GfxState.cc   |    9 +++++++++
 qt5/src/poppler-qt5.h |    4 ++++
 2 files changed, 13 insertions(+)

New commits:
commit e07c8b4784234383cb5ddcf1133ea91a772506e2
Author: Adam Reichold <adam.reichold at t-online.de>
Date:   Tue Jan 1 10:54:40 2019 +0100

    Avoid global display profile state becoming an uncontrolled memory leak by enforcing single initialization. Closes #654

diff --git a/poppler/GfxState.cc b/poppler/GfxState.cc
index 87b7ce03..4e3ccbfd 100644
--- a/poppler/GfxState.cc
+++ b/poppler/GfxState.cc
@@ -226,6 +226,10 @@ static unsigned int getCMSNChannels(cmsColorSpaceSignature cs);
 static cmsHPROFILE loadColorProfile(const char *fileName);
 
 void GfxColorSpace::setDisplayProfile(void *displayProfileA) {
+  if (displayProfile != nullptr) {
+    error(errInternal, -1, "The display color profile can only be set once before any rendering is done.");
+    return;
+  }
   displayProfile = displayProfileA;
   if (displayProfile != nullptr) {
     cmsHTRANSFORM transform;
@@ -249,6 +253,11 @@ void GfxColorSpace::setDisplayProfile(void *displayProfileA) {
 }
 
 void GfxColorSpace::setDisplayProfileName(GooString *name) {
+  if (displayProfile != nullptr) {
+    error(errInternal, -1, "The display color profile can only be set before any rendering is done.");
+    return;
+  }
+  delete displayProfileName;
   displayProfileName = name->copy();
 }
 
diff --git a/qt5/src/poppler-qt5.h b/qt5/src/poppler-qt5.h
index 4f06c47e..ddac7dfb 100644
--- a/qt5/src/poppler-qt5.h
+++ b/qt5/src/poppler-qt5.h
@@ -1102,6 +1102,8 @@ delete it;
 
 	  \param outputProfileA is a \c cmsHPROFILE of the LCMS library.
 
+	  \note This should be called before any rendering happens and only once during the lifetime of the current process.
+
 	   \since 0.12
 	*/
 	void setColorDisplayProfile(void *outputProfileA);
@@ -1110,6 +1112,8 @@ delete it;
 
 	  \param name is the name of the display profile to set.
 
+	  \note This should be called before any rendering happens.
+
 	   \since 0.12
 	*/
 	void setColorDisplayProfileName(const QString &name);


More information about the poppler mailing list