xcf: Fix crash on broken files

This commit is contained in:
Albert Astals Cid 2024-07-24 23:38:51 +02:00
parent acd6b3970c
commit 4478bc8d2b

View File

@ -1672,8 +1672,12 @@ bool XCFImageFormat::assignImageBytes(Layer &layer, uint i, uint j, const GimpPr
for (int y = 0; y < height; y++) {
uchar *dataPtr = bits + y * bytesPerLine;
uchar *alphaPtr = nullptr;
if (!layer.alpha_tiles.isEmpty())
alphaPtr = layer.alpha_tiles[j][i].scanLine(y);
if (!layer.alpha_tiles.isEmpty()) {
QImage &alphaTile = layer.alpha_tiles[j][i];
if (alphaTile.width() >= width && alphaTile.height() > y) {
alphaPtr = alphaTile.scanLine(y);
}
}
if (bpc == 4) {
#ifdef USE_FLOAT_IMAGES
if (precision < GimpPrecision::GIMP_PRECISION_HALF_LINEAR) {