[poppler] poppler/ArthurOutputDev.cc poppler/CairoOutputDev.cc poppler/Page.cc poppler/Stream.cc poppler/Stream.h utils/HtmlOutputDev.cc utils/ImageOutputDev.cc

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Mon May 11 00:39:58 PDT 2009


 poppler/ArthurOutputDev.cc |    1 +
 poppler/CairoOutputDev.cc  |   20 +++++++++++++++++---
 poppler/Page.cc            |    1 +
 poppler/Stream.cc          |    4 ++++
 poppler/Stream.h           |    3 +++
 utils/HtmlOutputDev.cc     |    1 +
 utils/ImageOutputDev.cc    |    1 +
 7 files changed, 28 insertions(+), 3 deletions(-)

New commits:
commit 5051ebed1477ff3f7721606f79d66d56a80c1145
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun May 10 19:10:51 2009 +0200

    Make sure ImageStream::close() is called after ImageStream::reset()

diff --git a/poppler/ArthurOutputDev.cc b/poppler/ArthurOutputDev.cc
index fe562fe..5d9c316 100644
--- a/poppler/ArthurOutputDev.cc
+++ b/poppler/ArthurOutputDev.cc
@@ -731,6 +731,7 @@ void ArthurOutputDev::drawImageMask(GfxState *state, Object *ref, Stream *str,
   cairo_pattern_destroy (pattern);
   cairo_surface_destroy (image);
   free (buffer);
+  imgStr->close ();
   delete imgStr;
 #endif
 }
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index 98adb7c..fa8c3cd 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -1134,11 +1134,13 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream *
   image = cairo_image_surface_create_for_data (buffer, CAIRO_FORMAT_A8,
 					       width, height, row_stride);
   if (image == NULL) {
+    imgStr->close();
     delete imgStr;
     return;
   }
   pattern = cairo_pattern_create_for_surface (image);
   if (pattern == NULL) {
+    imgStr->close();
     delete imgStr;
     return;
   }
@@ -1175,6 +1177,7 @@ void CairoOutputDev::drawImageMaskRegular(GfxState *state, Object *ref, Stream *
   cairo_pattern_destroy (pattern);
   cairo_surface_destroy (image);
   free (buffer);
+  imgStr->close();
   delete imgStr;
 }
 
@@ -1394,11 +1397,13 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream
   image = cairo_image_surface_create_for_data (buffer, CAIRO_FORMAT_A8,
       scaledWidth, scaledHeight, row_stride);
   if (image == NULL) {
+    imgStr->close();
     delete imgStr;
     return;
   }
   pattern = cairo_pattern_create_for_surface (image);
   if (pattern == NULL) {
+    imgStr->close();
     delete imgStr;
     return;
   }
@@ -1446,6 +1451,7 @@ void CairoOutputDev::drawImageMaskPrescaled(GfxState *state, Object *ref, Stream
   cairo_pattern_destroy (pattern);
   cairo_surface_destroy (image);
   free (buffer);
+  imgStr->close();
   delete imgStr;
 }
 
@@ -1485,9 +1491,8 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
 
   maskImage = cairo_image_surface_create_for_data (maskBuffer, CAIRO_FORMAT_A8,
 						 maskWidth, maskHeight, row_stride);
-
+  maskImgStr->close();
   delete maskImgStr;
-  maskStr->close();
 
   unsigned char *buffer;
   unsigned int *dest;
@@ -1521,12 +1526,14 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
 						 width, height, width * 4);
 
   if (image == NULL) {
+    imgStr->close();
     delete imgStr;
     return;
   }
   pattern = cairo_pattern_create_for_surface (image);
   maskPattern = cairo_pattern_create_for_surface (maskImage);
   if (pattern == NULL) {
+    imgStr->close();
     delete imgStr;
     return;
   }
@@ -1566,6 +1573,7 @@ void CairoOutputDev::drawMaskedImage(GfxState *state, Object *ref,
   cairo_surface_destroy (image);
   free (buffer);
   free (maskBuffer);
+  imgStr->close();
   delete imgStr;
 }
 
@@ -1601,8 +1609,8 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
   maskImage = cairo_image_surface_create_for_data (maskBuffer, CAIRO_FORMAT_A8,
 						 maskWidth, maskHeight, row_stride);
 
+  maskImgStr->close();
   delete maskImgStr;
-  maskStr->close();
 
   unsigned char *buffer;
   unsigned int *dest;
@@ -1637,12 +1645,14 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
 						 width, height, width * 4);
 
   if (image == NULL) {
+    imgStr->close();
     delete imgStr;
     return;
   }
   pattern = cairo_pattern_create_for_surface (image);
   maskPattern = cairo_pattern_create_for_surface (maskImage);
   if (pattern == NULL) {
+    imgStr->close();
     delete imgStr;
     return;
   }
@@ -1687,6 +1697,7 @@ void CairoOutputDev::drawSoftMaskedImage(GfxState *state, Object *ref, Stream *s
   free (buffer);
   free (maskBuffer);
 
+  imgStr->close();
   delete imgStr;
 }
 void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
@@ -1754,11 +1765,13 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
   }
 
   if (image == NULL) {
+   imgStr->close();
    delete imgStr;
    return;
   }
   pattern = cairo_pattern_create_for_surface (image);
   if (pattern == NULL) {
+    imgStr->close();
     delete imgStr;
     return;
   }
@@ -1793,6 +1806,7 @@ void CairoOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
   cairo_pattern_destroy (pattern);
   cairo_surface_destroy (image);
   free (buffer);
+  imgStr->close();
   delete imgStr;
 }
 
diff --git a/poppler/Page.cc b/poppler/Page.cc
index 1cc2cfb..e968851 100644
--- a/poppler/Page.cc
+++ b/poppler/Page.cc
@@ -563,6 +563,7 @@ GBool Page::loadThumb(unsigned char **data_out,
       }
     }
     *data_out = pixbufdata;
+    imgstr->close();
     delete imgstr;
   }
 
diff --git a/poppler/Stream.cc b/poppler/Stream.cc
index 4200101..64956e0 100644
--- a/poppler/Stream.cc
+++ b/poppler/Stream.cc
@@ -415,6 +415,10 @@ void ImageStream::reset() {
   str->reset();
 }
 
+void ImageStream::close() {
+  str->close();
+}
+
 GBool ImageStream::getPixel(Guchar *pix) {
   int i;
 
diff --git a/poppler/Stream.h b/poppler/Stream.h
index 2d1598f..8316e73 100644
--- a/poppler/Stream.h
+++ b/poppler/Stream.h
@@ -291,6 +291,9 @@ public:
   // Reset the stream.
   void reset();
 
+  // Close the stream previously reset
+  void close();
+
   // Gets the next pixel from the stream.  <pix> should be able to hold
   // at least nComps elements.  Returns false at end of file.
   GBool getPixel(Guchar *pix);
diff --git a/utils/HtmlOutputDev.cc b/utils/HtmlOutputDev.cc
index bda3846..03b8967 100644
--- a/utils/HtmlOutputDev.cc
+++ b/utils/HtmlOutputDev.cc
@@ -1414,6 +1414,7 @@ void HtmlOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
     free(row);
     imgList->append(fName);
     ++imgNum;
+    imgStr->close();
     delete imgStr;
 #else
     OutputDev::drawImage(state, ref, str, width, height, colorMap,
diff --git a/utils/ImageOutputDev.cc b/utils/ImageOutputDev.cc
index be3807f..f7d69d2 100644
--- a/utils/ImageOutputDev.cc
+++ b/utils/ImageOutputDev.cc
@@ -217,6 +217,7 @@ void ImageOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
 	p += colorMap->getNumPixelComps();
       }
     }
+    imgStr->close();
     delete imgStr;
 
     fclose(f);


More information about the poppler mailing list