From ba9ac942f0b27888648e21d8179f86448c953d96 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 17 Mar 2015 16:50:40 +0100 Subject: Add missing null check when detaching a QImage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit copy() may result in a failing malloc and thus return a QImage with a null d. Hence the need for a null check before incrementing detach_no. Task-number: QTBUG-41657 Change-Id: I868c37ef355fceaa1e2fc5f8a472e3dcc84dcadd Reviewed-by: aavit Reviewed-by: Jørgen Lind --- src/gui/image/qimage.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/gui/image') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 8ca58d4e5e..5cc1cf760f 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -1081,7 +1081,8 @@ void QImage::detach() if (d->ref.load() != 1 || d->ro_data) *this = copy(); - ++d->detach_no; + if (d) + ++d->detach_no; } } -- cgit v1.2.3