[poppler] patch for a progress callback [memory leak fix]

Damian Stewart lists at damianstewart.com
Fri Jan 4 00:42:37 PST 2013


Apologies for the spammage, but there's a memory leak in the previous patch. Fix it like this:


commit 52e6896f65f5b8f235ca765c744ac781bdd99517
Author: Damian at mba <damian at frey.NOSPAMco.nz>
Date:   Fri Jan 4 09:39:32 2013 +0100

    fix a memory leak in the progress callback setup

diff --git a/poppler/Page.cc b/poppler/Page.cc
index 110005c..0cb1f38 100644
--- a/poppler/Page.cc
+++ b/poppler/Page.cc
@@ -506,7 +506,7 @@ void Page::displaySlice(OutputDev *out, double hDPI, double vDPI,
                         void *annotDisplayDecideCbkData,
                         void (*progressCbk)(int pageNum, float progressPct, void* user_data),
                         void *progressCbkData ) {
-  Gfx *gfx, *dummyGfx;
+  Gfx *gfx;
   Object obj;
   Annots *annotList;
   int i;
@@ -529,10 +529,11 @@ void Page::displaySlice(OutputDev *out, double hDPI, double vDPI,
     if ( progressCbk ) {
       // create dummy output device to count operations
       OutputDev* dummyOutputDev = new DummyOutputDev();
-      dummyGfx = createGfx(dummyOutputDev, hDPI, vDPI, rotate, useMediaBox, crop, 
+      Gfx* dummyGfx = createGfx(dummyOutputDev, hDPI, vDPI, rotate, useMediaBox, crop, 
           sliceX, sliceY, sliceW, sliceH, printing, abortCheckCbk, abortCheckCbkData);
       dummyGfx->display(&obj);
       unsigned long totalOperations = dummyGfx->getOperationCount();
+      delete dummyGfx;
       // set progress callback on the real gfx object
       gfx->setProgressCallback( progressCbk, progressCbkData, num/*pageNum*/, totalOperations );
     }





More information about the poppler mailing list