diff --git a/src/gui/image/qgifhandler.cpp b/src/gui/image/qgifhandler.cpp index 2a9217a2..28823f84 100644 --- a/src/gui/image/qgifhandler.cpp +++ b/src/gui/image/qgifhandler.cpp @@ -356,7 +356,8 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, (*image) = QImage(swidth, sheight, format); bpl = image->bytesPerLine(); bits = image->bits(); - memset(bits, 0, image->byteCount()); + if (bits) + memset(bits, 0, image->byteCount()); } // Check if the previous attempt to create the image failed. If it @@ -417,6 +418,10 @@ int QGIFFormat::decode(QImage *image, const uchar *buffer, int length, backingstore = QImage(qMax(backingstore.width(), w), qMax(backingstore.height(), h), QImage::Format_RGB32); + if (backingstore.isNull()) { + state = Error; + return -1; + } memset(bits, 0, image->byteCount()); } const int dest_bpl = backingstore.bytesPerLine();