hi every one,

I'm having some problems with Magick++ under linux (openSuse), sometimes my
program hangs with a "memory corruption" other times with "corrupted
double-linked list", here is my code :
char *document=NULL, *header=NULL, *docType=NULL;
Text text;
Compression comp(1, sockG->threadContext);
long int docLength, i;

header = HTTPParser::getHeader(allReceive);
docLength = HTTPParser::getDocumentLength(header);
docType = HTTPParser::getDocumentType(header);
document = HTTPParser::getDocument(allReceive);
int j = strlen(text.getStrInt(docLength));
Magick::Blob blob((const void *)document, docLength);
Magick::Blob retBlob  = comp.getCompressedImage(blob);

i = text.getStrPos(header, "Content-Length: ", 0)+strlen("Content-Length:
");
char *newHeader = text.strReplace(header,
                 text.getStrInt(docLength),
                 i,
                 j
                );
memset(allReceive, 0, 1000*MAX_RECEIVE*sizeof(char));
memcpy(allReceive,
    newHeader,
    strlen(header)
    );
memcpy(allReceive + strlen(header), (char *)retBlob.data(), retBlob.length
());
receivedLen = retBlob.length() + strlen(header);
*********
Magick::Blob Compression::getCompressedImage( Magick::Blob blob )
{
    Magick::Image image(blob);
    Magick::Blob retBlob;


    image.magick( "JPEG" );
    image.quality(this->getQuality());
    image.write(&retBlob);
    return retBlob;
}
**********
and just in case I'm making a mistake here is the methods I'm using :

BUFFER HTTPParser::getDocument( BUFFER buff )
{
    int taille;
    char * ret;
    taille = getDocumentLength( buff );
    ret = (char *) malloc (taille*sizeof(char));
    memcpy(ret, strstr(buff, "\r\n\r\n")+sizeof("\r\n\r\n")-1, taille);
    return ret;
}

BUFFER HTTPParser::getHeader( BUFFER buff )
{
    char * buffer;
    int ind;
    for (ind=0;
buff[ind]!='\r'||buff[ind+1]!='\n'||buff[ind+2]!='\r'||buff[ind+3]!='\n';
ind+=1);
    buffer = (char*) malloc ((ind+5)*sizeof(char));
    strncpy(buffer, buff, (ind+4)*sizeof(char));
    return buffer;
}

my BackTrace is (in addition to the two bold lines) :

#11 0xb7d35621 in RelinquishMagickMemory (memory=0x0) at magick/memory.c:550
#12 0xb7d8a88d in DestroyString (string=0x8280f88 "\n         \n
\n         \n      ") at magick/string.c:772
#13 0xb7db32d0 in DestroyXMLTree (xml_info=0x8179a20) at magick/xml-tree.c
:553
#14 0xb7db32a4 in DestroyXMLTree (xml_info=0x8179640) at magick/xml-tree.c
:512
#15 0xb7db32a4 in DestroyXMLTree (xml_info=0x8179320) at magick/xml-tree.c
:512
#16 0xb7db32a4 in DestroyXMLTree (xml_info=0x8093470) at magick/xml-tree.c
:512
#17 0xb7db32a4 in DestroyXMLTree (xml_info=0x8093178) at magick/xml-tree.c
:512
#18 0xb7db32a4 in DestroyXMLTree (xml_info=0x8093068) at magick/xml-tree.c
:512
#19 0xb7db328c in DestroyXMLTree (xml_info=0x809a228) at magick/xml-tree.c
:510
#20 0xb7db328c in DestroyXMLTree (xml_info=0x8096020) at magick/xml-tree.c
:510
#21 0xb7d4ae78 in GetImageProperty (image=0x816e130, property=0xa47c071c
"xmp:sans") at magick/property.c:1434
#22 0xb7d4dbd2 in SetImageProfile (image=0x816e130, name=0xa47c276c "xmp",
profile=0x81772d8) at magick/profile.c:1243
#23 0xb7f3ffd0 in ReadProfile (jpeg_info=0xa47c5aa0) at coders/jpeg.c:562
#24 0xb7bd108b in jpeg_set_marker_processor () from /usr/lib/libjpeg.so.62
#25 0xb7bcebec in jinit_input_controller () from /usr/lib/libjpeg.so.62
#26 0xb7bcd073 in jpeg_consume_input () from /usr/lib/libjpeg.so.62
#27 0xb7bcd438 in jpeg_read_header () from /usr/lib/libjpeg.so.62
#28 0xb7f43047 in ReadJPEGImage (image_info=0x816a028, exception=0xa47c923c)
at coders/jpeg.c:718
#29 0xb7cb8055 in ReadImage (image_info=0x8165f20, exception=0xa47c923c) at
magick/constitute.c:389
#30 0xb7c8ebd6 in BlobToImage (image_info=0x815ebc0, blob=0x8157168,
length=31310, exception=0xa47c923c) at magick/blob.c:353
#31 0x08056700 in Magick::Image::read (this=0xa47c92c4, [EMAIL PROTECTED])
at Magick++/lib/Image.cpp:1452
#32 0x08056f20 in Image (this=0xa47c92c4, [EMAIL PROTECTED]) at
Magick++/lib/Image.cpp:142

any help will be welcome.

PS : sorry for my poor english.
_______________________________________________
Magick-developers mailing list
Magick-developers@imagemagick.org
http://studio.imagemagick.org/mailman/listinfo/magick-developers

Reply via email to