Bug in MagickEvaluateImages
Posted: 2017-03-30T18:52:39-07:00
I'm using IM 6.9.7-10 on Windows 10 Pro x64 and ran into a problem with MagickEvaluateImages in which it was crashing with a simple test program. I eventually tracked it down to the fact that I had forgotten to call MagickResetIterator after reading in the images and before calling MagickEvaluateImages.
This is the code:
I haven't figured out precisely what is wrong but I suspect that the iterator is at the end of the image list and that the code doesn't check for this before it proceeds. Presumably MagickEvaluateImages should return NULL if there isn't at least one image in the list.
It is possible that MagickSmushImages and MagickCombineImages have the same problem.
I haven't installed V7 yet but a brief look at the code suggests that it has the same problem.
Are you still updating/patching V6?
Pete
This is the code:
Code: Select all
#define MSG(s) MessageBox(NULL,s,"",MB_OK)
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include <wand/magick_wand.h>
void test_wand(LPTSTR lpCmdLine)
{
MagickWand *mw = NULL;
MagickWand *ew = NULL;
MagickWandGenesis();
mw = NewMagickWand();
MagickReadImage(mw,"http://www.imagemagick.org/Usage/compose/tile_water.jpg");
MagickReadImage(mw,"http://www.imagemagick.org/Usage/compose/tile_aqua.jpg");
//MSG("Files read");
//>>> THIS IS ESSENTIAL !!! It will crash when this is commented
// MagickResetIterator(mw);
ew = MagickEvaluateImages(mw,MeanEvaluateOperator);
//MSG("Done evaluate");
if(ew == NULL) {
MSG("MagickEvaluateImages returned NULL");
if(mw)mw = DestroyMagickWand(mw);
return;
}
MagickWriteImage(ew,"evaluateimages_tiles.jpg");
/* Clean up */
if(mw)mw = DestroyMagickWand(mw);
if(ew)ew = DestroyMagickWand(ew);
MagickWandTerminus();
}
It is possible that MagickSmushImages and MagickCombineImages have the same problem.
I haven't installed V7 yet but a brief look at the code suggests that it has the same problem.
Are you still updating/patching V6?
Pete