Memory leak in LevelColorsImage??

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
jcsm

Memory leak in LevelColorsImage??

Post by jcsm »

HI

I have this problem on v6.6.1 (Windows VS 9.0.30729.1 SP), this is reproducible with next source code, I tried with the deprecate function LevelImageColors with the same result, any idea?

Thank you
jcs

Code: Select all

//-------------------------------------------------------------------------------
	MagickWandGenesis();
	MagickWand *imageLeak = NewMagickWand();
	PixelWand *p1 = NULL,*p2 = NULL;
	p1 = NewPixelWand();
	p2 = NewPixelWand();
	PixelSetColor(p1, "rgb(10,10,10)");
	PixelSetColor(p2, "rgb(140,10,10)");
	MagickNewImage(imageLeak, 80, 80, p1 );
	MagickPixelPacket mp1,mp2;
	PixelGetMagickColor(p1, &mp1);
	PixelGetMagickColor(p2, &mp2);
	LevelColorsImage(imageLeak->images, &mp2, &mp1, MagickTrue ); //Memory Leak
	if (imageLeak != NULL ) 
		imageLeak = DestroyMagickWand(imageLeak );
	if (p1 != NULL ) 
		p1 = DestroyPixelWand(p1 );
	if (p2 != NULL ) 
		p2 = DestroyPixelWand(p2 );
	MagickWandTerminus();
//-------------------------------------------------------------------------------
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Memory leak in LevelColorsImage??

Post by el_supremo »

@Magick: LevelImageChannel does an AcquireCacheView and then a DestroyCacheView before returning. But LevelizeImageChannel does an Acquire without Destroy.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Memory leak in LevelColorsImage??

Post by magick »

Good catch. We'll get a patch into the ImageMagick Subversion trunk sometime today. Thanks.
jcsm

Re: Memory leak in LevelColorsImage??

Post by jcsm »

Thank you "el_supremo", I fixed it adding next code:

if (image_view != NULL )
image_view=DestroyCacheView(image_view);
Post Reply