diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c index 654fd998d6..d4195c5f0b 100644 --- a/libavcodec/qpeg.c +++ b/libavcodec/qpeg.c @@ -99,6 +99,8 @@ static void qpeg_decode_intra(QpegContext *qctx, uint8_t *dst, } } } else { + if (bytestream2_get_bytes_left(&qctx->buffer) < copy) + copy = bytestream2_get_bytes_left(&qctx->buffer); for(i = 0; i < copy; i++) { dst[filled++] = bytestream2_get_byte(&qctx->buffer); if (filled >= width) {