QPngHandlerPrivate *d = (QPngHandlerPrivate *)png_get_io_ptr(png_ptr);
QIODevice *in = d->q->device();
- if (d->state == QPngHandlerPrivate::ReadingEnd && !in->isSequential() && (in->size() - in->pos()) < 4 && length == 4) {
- // Workaround for certain malformed PNGs that lack the final crc bytes
- uchar endcrc[4] = { 0xae, 0x42, 0x60, 0x82 };
- memcpy(data, endcrc, 4);
- in->seek(in->size());
- return;
- }
-
- while (length) {
- int nr = in->read((char*)data, length);
- if (nr <= 0) {
- png_error(png_ptr, "Read Error");
- break;
- }
- length -= nr;
+ int nr = in->read((char*)data, length);
+ if (nr != length) {
+ png_error(png_ptr, "Read Error");
}
}