From f513561f6ce7bd5244bd47605d51012c040fe549 Mon Sep 17 00:00:00 2001 From: Marek Kasik Date: Tue, 22 Jan 2019 14:38:16 +0100 Subject: [PATCH] Avoid global display profile state leaking uncontrollably Resolves: #1646549 --- poppler-0.67.0-display-profile.patch | 63 ++++++++++++++++++++++++++++ poppler.spec | 10 ++++- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 poppler-0.67.0-display-profile.patch diff --git a/poppler-0.67.0-display-profile.patch b/poppler-0.67.0-display-profile.patch new file mode 100644 index 0000000..a9f5c58 --- /dev/null +++ b/poppler-0.67.0-display-profile.patch @@ -0,0 +1,63 @@ +From e07c8b4784234383cb5ddcf1133ea91a772506e2 Mon Sep 17 00:00:00 2001 +From: Adam Reichold +Date: Tue, 1 Jan 2019 10:54:40 +0100 +Subject: [PATCH] Avoid global display profile state becoming an uncontrolled + memory leak by enforcing single initialization. Closes #654 + +--- + poppler/GfxState.cc | 9 +++++++++ + qt5/src/poppler-qt5.h | 4 ++++ + 2 files changed, 13 insertions(+) + +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); +-- +2.20.1 + diff --git a/poppler.spec b/poppler.spec index 50d1ef7..38fda39 100644 --- a/poppler.spec +++ b/poppler.spec @@ -4,7 +4,7 @@ Summary: PDF rendering library Name: poppler Version: 0.67.0 -Release: 9%{?dist} +Release: 10%{?dist} License: (GPLv2 or GPLv3) and GPLv2+ and LGPLv2+ and MIT URL: http://poppler.freedesktop.org/ Source0: http://poppler.freedesktop.org/poppler-%{version}.tar.xz @@ -46,6 +46,9 @@ Patch14: poppler-0.67.0-filespec.patch # https://bugzilla.redhat.com/show_bug.cgi?id=1665266 Patch15: poppler-0.67.0-dummy-xref-entry.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=1646546 +Patch16: poppler-0.67.0-display-profile.patch + BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: gettext-devel @@ -276,6 +279,11 @@ test "$(pkg-config --modversion poppler-splash)" = "%{version}" %{_mandir}/man1/* %changelog +* Tue Jan 22 2019 Marek Kasik - 0.67.0-10 +- Avoid global display profile state becoming an uncontrolled +- memory leak +- Resolves: #1646549 + * Mon Jan 21 2019 Marek Kasik - 0.67.0-9 - Do not try to parse into unallocated XRef entry - Resolves: #1665268