Add new comment

random Crash with CRW file in memory stream

Hi.
I've found a random crash with MemoryStream and CR2.
The file is downloaded from edsdk api and i use open_buffer to unpack image.
I try to found it. It's like datastream make memory erro whith cr2 file. Crash always appear on memchr in libraw_datastream.h :

int get_ljpeg_byte() {
        if(offt<next_ff) return buf[offt++];
        int ret = buf[offt++];
        if(ret == 0xff) { if(buf[offt]==0x00) offt++; else return 0;}
        // find next 0xff
        unsigned char *p = (unsigned char*) memchr(buf+offt,0xff,size-offt);
        if(p)
            next_ff = p-buf;
        else
            next_ff = size;
        return ret;
    }
 <cpp>

Forums: