Fix possible crash when copying QImage.
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>
Wed, 20 Jun 2012 11:45:32 +0000 (13:45 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 21 Jun 2012 10:50:08 +0000 (12:50 +0200)
Task-number: QTBUG-14766

Change-Id: I82a4736dbd5ac08ede1b2bdccfa29a2009ebb4d8
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
src/gui/image/qimage.cpp

index 91af774..0b33010 100644 (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