windows Heap problems using Magick++

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
salukibob

windows Heap problems using Magick++

Post by salukibob »

Hello,

I'm just using Magick++ to convert an in memory Jpeg2000 image to a bitmap. The conversion functions correctly, but when the method returns, VStudio 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.

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;
  }
}
The code above is simplified, but should work. It works fine in terms of correctly putting a bitmap image into the output blob, but then causing a heap error when the function returns. Is there any cleanup i should be doing with the image object?

Thanks for any help,
Rob Smith
salukibob

Re: windows Heap problems using Magick++

Post by salukibob »

just to update, i've also tried creating the image object on the stack, instead of using the heap, and the heap error occurs when calling delete on the Makick::Image object. Can any developers help?

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
}
Post Reply