Project

General

Profile

Bug #1268 » image.diff

diff for src/image.cpp workaround for heap crash. - Ben Touchette, 28 Dec 2016 19:45

View differences:

trunk/src/image.cpp (revision 4696) → trunk/src/image.cpp (working copy)
387 387
                                ;
388 388

  
389 389
                // if ( offset > io.size() ) offset = 0; // Denial of service?
390
                DataBuf  buf(size*count + pad);  // allocate a buffer
390
               int buffer_size = size*count + pad;
391
               if (buffer_size < 4) buffer_size = 4;
392
                DataBuf  buf(buffer_size);  // allocate a buffer
391 393
                std::memcpy(buf.pData_,dir.pData_+8,4);  // copy dir[8:11] into buffer (short strings)
392
                if ( count*size > 4 ) {            // read into buffer
394
               if (count*size > 4) {            // read into buffer
393 395
                    size_t   restore = io.tell();  // save
394 396
                    io.seek(offset,BasicIo::beg);  // position
395 397
                    io.read(buf.pData_,count*size);// read
(3-3/3)