Page 1 of 1

Possible Memory Leak In Drawable.cpp

Posted: 2010-08-05T06:23:07-07:00
by dannyjames
Hi everybody,

while checking a a program of mine with Valgrind, I noticed a small memory leak which (to me) seems to lead into the Magick++ code.
In Drawable.h, at line 1045, there is a call to:

Code: Select all

delete _dasharray;
This may not free the memory correctly, I think it should be:

Code: Select all

delete[] _dasharray;
I could't see a place to attach diffs so I will just post it here (as its really rather small)

Code: Select all

Index: Magick++/lib/Drawable.cpp
===================================================================
--- Magick++/lib/Drawable.cpp   (revision 2378)
+++ Magick++/lib/Drawable.cpp   (working copy)
@@ -1042,7 +1042,7 @@
 }
 Magick::DrawableDashArray::~DrawableDashArray( void )
 {
-  delete _dasharray;
+  delete[] _dasharray;
   _size = 0;
   _dasharray = 0;
 }
Could this be the fix?

Best Regards

Danny

Re: Possible Memory Leak In Drawable.cpp

Posted: 2010-08-05T06:55:17-07:00
by magick
Good catch. We'll get the patch in next point release of ImageMagick.