mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 19:02:59 +00:00
drop workaround for malformed PNGs
while at it, read the data in single pass as is done in the TIFF image format handler for an example Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
70c523fb13
commit
b1e1f18970
1 changed files with 3 additions and 15 deletions
|
@ -123,21 +123,9 @@ static void iod_read_fn(png_structp png_ptr, png_bytep data, png_size_t length)
|
|||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue