[poppler] [PATCH 1/5] Avoid leaving pointers to free'd memory

David Benjamin davidben at MIT.EDU
Thu Jan 21 21:26:59 PST 2010


Fixes potential free'd memory access introduced by
3a94e8ce90c0a4d11c5c5aa8805c167c8a0434e5. I don't think this is actually
possible in the current code; we push/pop before and after rendering a
PDF, so the bottom state should never have a mask.

Still, better to clean this up.
---
 poppler/CairoOutputDev.cc |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 9a0f3be..c0b7102 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -271,10 +271,9 @@ void CairoOutputDev::restoreState(GfxState *state) {
   updateBlendMode(state);
 
   MaskStack* ms = maskStack;
-  if (mask)
-    cairo_pattern_destroy(mask);
-
   if (ms) {
+    if (mask)
+      cairo_pattern_destroy(mask);
     mask = ms->mask;
     maskStack = ms->next;
     delete ms;
-- 
1.6.6.137.g8333d.dirty



More information about the poppler mailing list