Page 1 of 1

windows Heap problems using Magick++

Posted: 2010-07-15T03:06:24-07:00
by salukibob
Hello,

I've posted this query on the User forum, but so far no luck, so hopefully a developer can help...

I'm just using Magick++ to convert an in memory Jpeg2000 image to a bitmap. The conversion functions correctly, but when the method returns, VisualStudio throws a debug assertion stating an invalid address specified for RtlValidateHeap(). Looking at the call trace, this occurs inside the CORE_DB_Magick++_.dll when calling the delete operator on the Magick::Image object.

The code I'm using is pretty simple, and is below.

Code: Select all

void imageproc( void* pdata, size_t size )
{
  Image image;
  Blob in_b, out_b;

  // initialise magick
  Initializemagick( NULL );

  // assign data to a blob
  in_b.updateNoCopy( pdata, size );

  // read the bloc data into an image object, set the new format, and write to the output blob
  try {
    image.read( in_b );
    image.magick( "bmp" );
    image.write( &out_b );
  }
  catch( Error& error ) {
    ...
    return;
  }
}
Further to this, I've also tried creating the image object on the stack, instead of the heap, but the heap error still occurs when calling delete on the Magick::Image object. See below.

Code: Select all

void imageproc( void* pdata, size_t size )
{
  Image* image = new Image;
  Blob in_b, out_b;

  // initialise magick
  Initializemagick( NULL );

  // assign data to a blob
  in_b.updateNoCopy( pdata, size );

  // read the bloc data into an image object, set the new format, and write to the output blob
  try {
    image->read( in_b );
    image->magick( "bmp" );
    image->write( &out_b );
  }
  catch( Error& error ) {
    ...
    return;
  }

  // clearup
  delete image;  -  this causes windows to trigger a breakpoint
}
This code really looks as simple as it can get, but I just cannot get rid of these heap errors. Am I supposed to be doing some cleanup on the image object? The version of ImageMagick is the latest download 6.6.3, that I compiled from source.

Thanks for any help you can give,
Regards
Rob Smith