When I process a jpg like
http://www.acrosser.com.tw/DownLoad/200 ... 336734.jpg
my test code is core dump
Code: Select all
#include <Magick++.h>
#include <string>
#include<stdio.h>
using namespace std;
using namespace Magick;
#define nnum 6000000
int main(){
FILE * fp;
fp = fopen("readimage.jpg", "r");
if(fp==NULL)
{
return 0;
}
char *test = new char[6000000];
fread(test, sizeof(test), nnum, fp);
Blob blob(test, sizeof(test)*nnum);
Image image;
try
{
image.read( blob );
}
catch( Exception &error_ )
{
printf("Caught exception:%s\n", error_.what());
return EXIT_FAILURE;
}
delete test;
return EXIT_SUCCESS;
}
==6513== 31,915 bytes in 1 blocks are definitely lost in loss record 20 of 22
==6513== at 0x4A05809: malloc (vg_replace_malloc.c:149)
==6513== by 0x5287171: NewXMLTree (in /usr/lib64/libMagickCore.so.1.0.0)
==6513== by 0x5235D16: GetImageProperty (in /usr/lib64/libMagickCore.so.1.0.0)
==6513== by 0x5237E2E: SetImageProfile (in /usr/lib64/libMagickCore.so.1.0.0)
==6513== by 0x9460591: (within /usr/lib64/ImageMagick-6.4.3/modules-Q16/coders/jpeg.so)
==6513== by 0x396BE10D1C: (within /usr/lib64/libjpeg.so.62.0.0)
==6513== by 0x396BE0EA1E: (within /usr/lib64/libjpeg.so.62.0.0)
==6513== by 0x396BE0CF61: jpeg_consume_input (in /usr/lib64/libjpeg.so.62.0.0)
==6513== by 0x396BE0D312: jpeg_read_header (in /usr/lib64/libjpeg.so.62.0.0)
==6513== by 0x9460FB3: (within /usr/lib64/ImageMagick-6.4.3/modules-Q16/coders/jpeg.so)
==6513== by 0x51BACCF: ReadImage (in /usr/lib64/libMagickCore.so.1.0.0)
==6513== by 0x51927DD: BlobToImage (in /usr/lib64/libMagickCore.so.1.0.0)
Is there anything memory leak?
anyway
in 32bit system there is
==18580== Source and destination overlap in memcpy(0x4D6B028, 0x47B2028, 24000000)
==18580== at 0x4006949: memcpy (mc_replace_strmem.c:402)
==18580== by 0x40405C0: Magick::BlobRef::BlobRef(void const*, unsigned) (in /usr/lib/libMagick++.so.1.0.0)
==18580== by 0x403FF22: Magick::Blob::Blob(void const*, unsigned) (in /usr/lib/libMagick++.so.1.0.0)
==18580== by 0x80489CC: main (magc.cpp:35)
and core dump too
please help!