Details
-
Bug
-
Resolution: Incomplete
-
Not Evaluated
-
None
-
5.12.2
-
None
Description
Minimial repro:
QImageimage(4, 4, QImage::Format_ARGB32_Premultiplied); image.fill(0); image.data_ptr()->checkForAlphaPixels();
triggers: "SUMMARY: MemorySanitizer: use-of-uninitialized-value image/qimage.cpp:195:9 in QImageData::checkForAlphaPixels() const"
when it accesses the `bits` in the block
{{}}
case QImage::Format_ARGB32_Premultiplied: { const uchar *bits = data; for (int y=0; y<height && !has_alpha_pixels; ++y) { uint alphaAnd = 0xff000000; for (int x=0; x<width; ++x) alphaAnd &= reinterpret_cast<const uint*>(bits)[x]; has_alpha_pixels = (alphaAnd != 0xff000000);bits += bytes_per_line; } } break;
The simplest fix I've found is to initialize the QIamgeData.data member with `calloc` instead of `malloc`:
QImageData * QImageData::create(const QSize &size, QImage::Format format)
{
[...]
d->data = (uchar *)calloc(d->nbytes, 1);
[...]
}