diff options
author | Eirik Aavitsland <eirik.aavitsland@theqtcompany.com> | 2015-03-03 09:39:22 +0100 |
---|---|---|
committer | aavit <eirik.aavitsland@theqtcompany.com> | 2015-03-04 10:53:00 +0000 |
commit | 509bc7e59c69937900cf258e64889a6e88edbcf0 (patch) | |
tree | 787951c2d0886d6569c5767bcb9d014bb2a5a851 /src/gui/image | |
parent | 227bb20dedc4156c1a4653d55252b0790fd1ae75 (diff) | |
download | qtbase-509bc7e59c69937900cf258e64889a6e88edbcf0.tar.gz |
Fix another crash when converting format of buffer-created QImage
This continues 68762151dbf45fbb44e140ac2ad13dbe8d357352
When doing format conversion, the optimized inplace codepath did not
check if the image data was external, i.e. if the QImage had been
created by the constructor taking an existing external buffer.
The previous commit fixed the readonly case. But in the case of the
QImage constructor taking non-const uchar*, data will be read-write,
but still external. This would of course crash if the converter tries
to realloc it.
Task-number: QTBUG-44610
Change-Id: I94d275d464e8af221682b538fc3e4897a59c061e
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'src/gui/image')
-rw-r--r-- | src/gui/image/qimage_conversions.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index b2681f4261..bd40d0d4fc 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -716,6 +716,8 @@ static bool convert_BGR30_to_RGB30_inplace(QImageData *data, Qt::ImageConversion 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; const int depth = 32; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -768,6 +770,8 @@ static bool convert_indexed8_to_ARGB_PM_inplace(QImageData *data, Qt::ImageConve static bool convert_indexed8_to_RGB_inplace(QImageData *data, Qt::ImageConversionFlags) { Q_ASSERT(data->format == QImage::Format_Indexed8); + if (!data->own_data) + return false; const int depth = 32; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -817,6 +821,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; const int depth = 16; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; @@ -872,6 +878,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; const int depth = 16; const int dst_bytes_per_line = ((data->width * depth + 31) >> 5) << 2; |