plug-ins: fix #6871 indexed tga file cannot be saved

Exporting an image to TGA fails with a crash when it's an indexed image
with alpha channel. We were not taking into account that even though
the output is 1 byte per pixel, the input should allocate memory for
2 bytes per pixel (1 color index and 1 alpha channel).
This commit is contained in:
Jacob Boerema 2022-01-18 14:57:35 -05:00
parent 1c8aad4f68
commit 059599fc78
1 changed files with 4 additions and 1 deletions

View File

@ -1353,7 +1353,10 @@ save_image (GFile *file,
fputc (0, fp);
}
pixels = g_new (guchar, width * out_bpp);
if (dtype == GIMP_INDEXEDA_IMAGE)
pixels = g_new (guchar, width * 2);
else
pixels = g_new (guchar, width * out_bpp);
data = g_new (guchar, width * out_bpp);
for (row = 0; row < height; ++row)