summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qvolatileimage.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>2011-09-30 12:52:17 +0300
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>2011-09-30 13:39:36 +0300
commit6570a4612ebf128a140c0ed66ac83bfaf9670b44 (patch)
tree0c628251193806b74a3d8ec29df0f15ffe944c0c /src/gui/image/qvolatileimage.cpp
parentc4699f8940d4bb0ecd462f323c6acc3619b15b1c (diff)
Do not crash in copy() of pixmaps without an underlying bitmap
If CFbsBitmap::Create() fails for some reason (e.g. due to lack of memory), we may end up with a QVolatileImage for which the underlying bitmap pointer is null, resulting in the QImage wrapper being null too. The copyFrom() function was not checking for this situation and started to copy data blindly to the null QImage's bits(), which is a null pointer. This is now fixed so no copying occurs in such a scenario. Task-number: QTTH-1446 Reviewed-by: Sami Merila
Diffstat (limited to 'src/gui/image/qvolatileimage.cpp')
-rw-r--r--src/gui/image/qvolatileimage.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/gui/image/qvolatileimage.cpp b/src/gui/image/qvolatileimage.cpp
index 9734c82494..350d70ff42 100644
--- a/src/gui/image/qvolatileimage.cpp
+++ b/src/gui/image/qvolatileimage.cpp
@@ -248,12 +248,14 @@ void QVolatileImage::copyFrom(QVolatileImage *source, const QRect &rect)
const uchar *sptr = srcImgRef.constBits() + r.y() * srcbpl;
beginDataAccess();
QImage &dstImgRef(imageRef());
- int dstbpl = dstImgRef.bytesPerLine();
- uchar *dptr = dstImgRef.bits();
- for (int y = 0; y < r.height(); ++y) {
- qMemCopy(dptr, sptr + r.x() * srcbpp, r.width() * srcbpp);
- sptr += srcbpl;
- dptr += dstbpl;
+ if (!dstImgRef.isNull()) {
+ int dstbpl = dstImgRef.bytesPerLine();
+ uchar *dptr = dstImgRef.bits();
+ for (int y = 0; y < r.height(); ++y) {
+ qMemCopy(dptr, sptr + r.x() * srcbpp, r.width() * srcbpp);
+ sptr += srcbpl;
+ dptr += dstbpl;
+ }
}
endDataAccess();
source->endDataAccess(true);