From 987be62d43d823aae3f0155340200669b4bc09d3 Mon Sep 17 00:00:00 2001 From: Jaime Velasco Juan Date: Sat, 24 Feb 2018 11:38:14 +0000 Subject: [PATCH] CairoOutputDev: derive image surface UNIQUE_ID from its contents Otherwise, when rendering several documents into the same cairo_surface the same ID could be used and cairo would reuse the first one even when they are unrelated. https://bugs.freedesktop.org/show_bug.cgi?id=104864 --- poppler/CairoOutputDev.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index bc83b807..30263a73 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -65,6 +65,7 @@ #include "CairoRescaleBox.h" #include "UnicodeMap.h" #include "JBIG2Stream.h" +#include "Decrypt.h" //------------------------------------------------------------------------ // #define LOG_CAIRO @@ -3052,8 +3053,14 @@ void CairoOutputDev::setMimeData(GfxState *state, Stream *str, Object *ref, #if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1, 11, 2) if (ref && ref->isRef()) { + char digest[16]; + char surface_id[33]; + md5((Guchar*)strBuffer, len, (Guchar*)digest); + sprintf(surface_id, "poppler-surface-%x%x%x%x%x%x%x%x", digest[0], + digest[1], digest[2], digest[3], digest[4], digest[5], + digest[6], digest[7]); status = setMimeIdFromRef(image, CAIRO_MIME_TYPE_UNIQUE_ID, - "poppler-surface-", ref->getRef()); + surface_id, ref->getRef()); } #endif if (!status) { -- 2.16.2