QXbmHandler: fix missing NUL-termination

The buffer is fed into strstr() on the next loop iteration, but
strstr() expects a NUL-terminated string.

In the equivalent code some lines up, the buffer is explicitly
terminated, and we never write the last character of the buffer again,
so we'll not fall off the end of the buffer, but if we read less bytes
than in the last line, we'll parse garbage from the previous line.

Change-Id: I354e1ce1dea71188942305190500b4778a69b4ff
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
bb10
Marc Mutz 2016-10-20 23:43:26 +02:00
parent f2205c48c2
commit 083d8caee1
1 changed files with 1 additions and 0 deletions

View File

@ -157,6 +157,7 @@ static bool read_xbm_body(QIODevice *device, int w, int h, QImage *outImage)
} else { // read another line
if ((readBytes = device->readLine(buf,buflen)) <= 0) // EOF ==> truncated image
break;
buf[readBytes] = '\0';
p = buf + QByteArray::fromRawData(buf, readBytes).indexOf("0x");
}
}