[Digikam-devel] extragear/graphics/digikam/libs/dimg

Marcel Wiesweg marcel.wiesweg at gmx.de
Sat Jan 21 22:37:38 GMT 2006


SVN commit 501049 by mwiesweg:

digikam from trunk: Dimg fixes

- fix memory leak: added missing deref() in DImg::copy()
  The object that is copied would leak its memory
- fix crash in jpegloader

CCMAIL:digikam-devel at kde.org



 M  +2 -0      dimg.cpp  
 M  +1 -1      dimgloader.cpp  
 M  +6 -6      loaders/jpegloader.cpp  


--- trunk/extragear/graphics/digikam/libs/dimg/dimg.cpp #501048:501049
@@ -780,6 +780,8 @@
         m_priv->data = new uchar[size];
         memcpy(m_priv->data, old->data, size);
     }
+
+    old->deref();
 }
 
 void DImg::crop(QRect rect)
--- trunk/extragear/graphics/digikam/libs/dimg/dimgloader.cpp #501048:501049
@@ -40,7 +40,7 @@
     // Progress slice is the part of 100% concerned with the current granularity
     // (E.g. in a loop only the values from 10% to 90% are used, then progressSlice is 0.8)
     // Current default is 1/20, that is progress info every 5%
-    int granularity = (total / (20 * progressSlice)) / observer->granularity();
+    int granularity = (int)(( total / (20 * progressSlice)) / observer->granularity());
     return granularity ? granularity : 1;
 }
 
--- trunk/extragear/graphics/digikam/libs/dimg/loaders/jpegloader.cpp #501048:501049
@@ -171,7 +171,7 @@
 
     int w = cinfo.output_width;
     int h = cinfo.output_height;
-    uchar *dest;
+    uchar *dest = 0;
     
     if (loadImageData)
     {
@@ -205,9 +205,9 @@
             return false;
         }
     
-        ptr2 = new uchar[w * h * 4];
+        dest = new uchar[w * h * 4];
     
-        if (!ptr2)
+        if (!dest)
         {
             delete [] data;
             jpeg_destroy_decompress(&cinfo);
@@ -216,7 +216,7 @@
             return false;
         }
     
-        dest  = ptr2;
+        ptr2  = dest;
         count = 0;
         prevy = 0;
     
@@ -235,7 +235,7 @@
                     if (!observer->continueQuery(m_image))
                     {
                         delete [] data;
-                        delete [] ptr2;
+                        delete [] dest;
                         jpeg_destroy_decompress(&cinfo);
                         fclose(file);
                         return false;
@@ -280,7 +280,7 @@
                     if (!observer->continueQuery(m_image))
                     {
                         delete [] data;
-                        delete [] ptr2;
+                        delete [] dest;
                         jpeg_destroy_decompress(&cinfo);
                         fclose(file);
                         return false;



More information about the Digikam-devel mailing list