diff --git a/libavcodec/sunrast.c b/libavcodec/sunrast.c index 9e49c4f275..cc27838f5b 100644 --- a/libavcodec/sunrast.c +++ b/libavcodec/sunrast.c @@ -163,8 +163,10 @@ static int sunrast_decode_frame(AVCodecContext *avctx, AVFrame *p, x = 0; while (ptr != end && buf < buf_end) { run = 1; - if (buf_end - buf < 1) + if (buf_end - buf < 1) { + av_freep(&ptr2); return AVERROR_INVALIDDATA; + } if ((value = *buf++) == RLE_TRIGGER) { run = *buf++ + 1;