diff --git a/libavcodec/sgidec.c b/libavcodec/sgidec.c index 4e8fd31ef1..f11efd05ee 100644 --- a/libavcodec/sgidec.c +++ b/libavcodec/sgidec.c @@ -58,7 +58,7 @@ static int expand_rle_row(SgiState *s, uint8_t *out_buf, } /* Check for buffer overflow. */ - if(out_buf + pixelstride * count >= out_end) return -1; + if(out_buf + pixelstride * (count-1) >= out_end) return -1; if (pixel & 0x80) { while (count--) {