Possible Memory Leak In Drawable.cpp

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
dannyjames

Possible Memory Leak In Drawable.cpp

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Possible Memory Leak In Drawable.cpp

Post by magick »

Good catch. We'll get the patch in next point release of ImageMagick.
Post Reply