From e95fce3084d5d52b6535cc7a8b7dd6883ffcdabd Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Thu, 1 Oct 2015 20:50:23 +0800 Subject: [PATCH] Fix potential crash when memory allocation failed. Closes #3877. --- src/gui/properties/pieceavailabilitybar.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gui/properties/pieceavailabilitybar.cpp b/src/gui/properties/pieceavailabilitybar.cpp index f6e4e53f9..284224d54 100644 --- a/src/gui/properties/pieceavailabilitybar.cpp +++ b/src/gui/properties/pieceavailabilitybar.cpp @@ -29,6 +29,7 @@ */ #include +#include #include "pieceavailabilitybar.h" PieceAvailabilityBar::PieceAvailabilityBar(QWidget *parent) : @@ -156,8 +157,11 @@ int PieceAvailabilityBar::mixTwoColors(int &rgb1, int &rgb2, float ratio) void PieceAvailabilityBar::updateImage() { - // qDebug() << "updateImageAv"; QImage image2(width() - 2, 1, QImage::Format_RGB888); + if (image2.isNull()) { + qDebug() << "QImage image2() allocation failed, width():" << width(); + return; + } if (m_pieces.empty()) { image2.fill(0xffffff);