[poppler] Branch 'poppler-0.8' - poppler/Page.cc

Albert Astals Cid aacid at kemper.freedesktop.org
Mon May 26 11:42:00 PDT 2008


 poppler/Page.cc |   35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

New commits:
commit cf552e8246f0000605005fa5bb7dd06fea97636a
Author: Albert Astals Cid <aacid at kde.org>
Date:   Mon May 26 20:38:59 2008 +0200

    Do not leak memory if data_out is NULL

diff --git a/poppler/Page.cc b/poppler/Page.cc
index b28a3ee..90417e1 100644
--- a/poppler/Page.cc
+++ b/poppler/Page.cc
@@ -518,30 +518,31 @@ GBool Page::loadThumb(unsigned char **data_out,
     goto fail1;
   }
 
-  pixbufdata = (unsigned char *) gmalloc(pixbufdatasize);
-  p = pixbufdata;
-  imgstr = new ImageStream(str, width,
+  if (data_out) {
+    pixbufdata = (unsigned char *) gmalloc(pixbufdatasize);
+    p = pixbufdata;
+    imgstr = new ImageStream(str, width,
 			   colorMap->getNumPixelComps(),
 			   colorMap->getBits());
-  imgstr->reset();
-  for (row = 0; row < height; ++row) {
-    for (col = 0; col < width; ++col) {
-      Guchar pix[gfxColorMaxComps];
-      GfxRGB rgb;
-
-      imgstr->getPixel(pix);
-      colorMap->getRGB(pix, &rgb);
-
-      *p++ = colToByte(rgb.r);
-      *p++ = colToByte(rgb.g);
-      *p++ = colToByte(rgb.b);
+    imgstr->reset();
+    for (row = 0; row < height; ++row) {
+      for (col = 0; col < width; ++col) {
+        Guchar pix[gfxColorMaxComps];
+        GfxRGB rgb;
+
+        imgstr->getPixel(pix);
+        colorMap->getRGB(pix, &rgb);
+
+        *p++ = colToByte(rgb.r);
+        *p++ = colToByte(rgb.g);
+        *p++ = colToByte(rgb.b);
+      }
     }
+    *data_out = pixbufdata;
   }
 
   success = gTrue;
 
-  if (data_out)
-    *data_out = pixbufdata;
   if (width_out)
     *width_out = width;
   if (height_out)


More information about the poppler mailing list