diff --git a/plug-ins/file-sgi/sgi-lib.c b/plug-ins/file-sgi/sgi-lib.c index 7fd61d04b3..c26e24e883 100644 --- a/plug-ins/file-sgi/sgi-lib.c +++ b/plug-ins/file-sgi/sgi-lib.c @@ -680,7 +680,7 @@ read_rle8(sgi_t *sgip, /* I - SGI image to read from */ return (-1); length ++; - count = ch & 127; + count = MIN (ch & 127, xsize); if (count == 0) break; @@ -725,7 +725,7 @@ read_rle16(sgi_t *sgip, /* I - SGI image to read from */ return (-1); length ++; - count = ch & 127; + count = MIN (ch & 127, xsize); if (count == 0) break;