[FFmpeg-cvslog] avcodec/sunrast: fix leak in sunrast_decode_frame()

Lidong Yan git at videolan.org
Fri Jul 4 00:08:01 EEST 2025


ffmpeg | branch: master | Lidong Yan <yldhome2d2 at gmail.com> | Sun Jun 29 14:45:25 2025 +0800| [98afcd3da776df40955257daf63b6bf8c1fd764e] | committer: Michael Niedermayer

avcodec/sunrast: fix leak in sunrast_decode_frame()

In sunrast_decode_frame(), we use av_malloc_array() allocates memory
to ptr and ptr2. However if buf_end - buf < 1, this function returns
error code without freeing this memory thus cause a leak. Add av_freep()
before return.

Signed-off-by: Lidong Yan <502024330056 at smail.nju.edu.cn>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=98afcd3da776df40955257daf63b6bf8c1fd764e
---

 libavcodec/sunrast.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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;



More information about the ffmpeg-cvslog mailing list