plug-ins: Check for failure when reading uncompressed psp channels

When we fail to read enough bytes when reading uncompressed psp
channels, return with an error.
The error message was copied from the PSD reader so this should not
be affected by the string freeze.

(cherry picked from commit bafb005637)
This commit is contained in:
Jacob Boerema 2025-12-20 10:40:17 -05:00 committed by Bruno Lopes
parent 8f51394495
commit 20dd7fdee5

View file

@ -1613,9 +1613,14 @@ read_channel_data (FILE *f,
{
guchar *p, *q;
fread (buf, width, 1, f);
if (fread (buf, 1, width, f) != width)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error reading data. Most likely unexpected end of file."));
return -1;
}
/* Contrary to what the PSP specification seems to suggest
scanlines are not stored on a 4-byte boundary. */
scanlines are not stored on a 4-byte boundary. */
p = buf;
q = pixels[y] + offset;
for (i = 0; i < width; i++)
@ -1631,9 +1636,14 @@ read_channel_data (FILE *f,
{
guint16 *p, *q;
fread (buf, width * ia->bytes_per_sample, 1, f);
if (fread (buf, ia->bytes_per_sample, width, f) != width)
{
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("Error reading data. Most likely unexpected end of file."));
return -1;
}
/* Contrary to what the PSP specification seems to suggest
scanlines are not stored on a 4-byte boundary. */
scanlines are not stored on a 4-byte boundary. */
p = (guint16 *) buf;
q = (guint16 *) (pixels[y] + offset);
for (i = 0; i < width; i++)