From c2b7841843f05fe902e6a94aee2c3f33b169009e Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Tue, 7 Jun 2016 16:52:13 +0200 Subject: Finally fix crash in inplace-modified data-constructed images Avoid all inplace modification of images using external data buffers. Since the QImage methods are documented to create a (modified) copy, there is afterwards no API requirement on the lifetime of the data buffer. This patch supersedes 509bc7e59c69937900cf258e64889a6e88edbcf0 Task-number: QTBUG-53721 Change-Id: I3ccc01619eb61d8630104449394e0b76df0af695 Reviewed-by: Friedemann Kleint Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/image/qimage_conversions.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/gui/image/qimage_conversions.cpp') diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index cc79e73534..7b8d88ba72 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -763,8 +763,8 @@ static bool convert_A2RGB30_PM_to_ARGB_inplace(QImageData *data, Qt::ImageConver static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_Indexed8); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); + const int depth = 32; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -817,8 +817,8 @@ static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConve static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_Indexed8); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); + const int depth = 32; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -868,8 +868,7 @@ static bool convert_indexed8_to_ARGB_inplace(QImageData *data, Qt::ImageConversi static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversionFlags flags) { Q_ASSERT(data->format == QImage::Format_Indexed8); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); if (data->has_alpha_clut) { for (int i = 0; i < data->colortable.size(); ++i) @@ -886,8 +885,8 @@ static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversio static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_Indexed8); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); + const int depth = 16; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -943,8 +942,8 @@ static bool convert_indexed8_to_RGB16_inplace(QImageData *data, Qt::ImageConvers static bool convert_RGB_to_RGB16_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_RGB32); - if (!data->own_data) - return false; + Q_ASSERT(data->own_data); + const int depth = 16; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; -- cgit v1.2.3