PPM image format: avoid useless processing on truncated files
For ascii formatted files, the handler would not stop processing on a premature EOF, but instead continue to fill the whole image memory area byte by byte. This could lead to unexpected CPU exhaustion in the case of a small image file declaring huge image dimensions, but having no content. Instead, check for EOF for each scanline and quit processing if found. Change-Id: I8dbcd7eb34553873e49706d61b5752f22e04eb6a Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>bb10
parent
fee16baca1
commit
b4ed054e2f
|
|
@ -182,7 +182,8 @@ static bool read_pbm_body(QIODevice *device, char type, int w, int h, int mcc, Q
|
|||
} else { // read ascii data
|
||||
uchar *p;
|
||||
int n;
|
||||
for (y=0; y<h; y++) {
|
||||
char buf;
|
||||
for (y = 0; (y < h) && (device->peek(&buf, 1) == 1); y++) {
|
||||
p = outImage->scanLine(y);
|
||||
n = pbm_bpl;
|
||||
if (nbits == 1) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue