Fix possible crash when copying QImage.

Task-number: QTBUG-14766

Change-Id: I82a4736dbd5ac08ede1b2bdccfa29a2009ebb4d8
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
This commit is contained in:
Kim Motoyoshi Kalland 2012-06-20 13:45:32 +02:00 committed by Qt by Nokia
parent f717c19469
commit fde71d1ae7

View File

@ -1117,7 +1117,7 @@ QImage QImage::copy(const QRect& r) const
// Qt for Embedded Linux can create images with non-default bpl
// make sure we don't crash.
if (image.d->nbytes != d->nbytes) {
int bpl = image.bytesPerLine();
int bpl = qMin(bytesPerLine(), image.bytesPerLine());
for (int i = 0; i < height(); i++)
memcpy(image.scanLine(i), scanLine(i), bpl);
} else