[FFmpeg-cvslog] avformat/rtsp: free the alloc memory if failed

Limin Wang git at videolan.org
Tue Dec 7 15:02:50 EET 2021


ffmpeg | branch: master | Limin Wang <lance.lmwang at gmail.com> | Sun Dec  5 21:13:51 2021 +0800| [f210766a55ea2db85b01038e0f4a4b8891d1903b] | committer: Limin Wang

avformat/rtsp: free the alloc memory if failed

Reviewed-by: Martin Storsjö <martin at martin.st>
Signed-off-by: Limin Wang <lance.lmwang at gmail.com>

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

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

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 47120fdf61..5cffe0b6b5 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1245,8 +1245,10 @@ start:
         content = av_malloc(content_length + 1);
         if (!content)
             return AVERROR(ENOMEM);
-        if (ffurl_read_complete(rt->rtsp_hd, content, content_length) != content_length)
+        if (ffurl_read_complete(rt->rtsp_hd, content, content_length) != content_length) {
+            av_freep(&content);
             return AVERROR(EIO);
+        }
         content[content_length] = '\0';
     }
     if (content_ptr)



More information about the ffmpeg-cvslog mailing list