diff mbox series

[FFmpeg-devel,v3,2/6] avformat/rtspdec: fix mem leaks in listen mode if init fails

Message ID 20201012203609.41647-2-andriy.gelman@gmail.com
State Accepted
Commit 38bc4ba142b2304b2a0e2d86f271a28d51250fb9
Headers show
Series [FFmpeg-devel,v3,1/6] avformat/rtspdec: add network init to listen mode | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Andriy Gelman Oct. 12, 2020, 8:36 p.m. UTC
From: Andriy Gelman <andriy.gelman@gmail.com>

Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
---
 libavformat/rtspdec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Martin Storsjö Nov. 20, 2020, 8:22 a.m. UTC | #1
On Mon, 12 Oct 2020, Andriy Gelman wrote:

> From: Andriy Gelman <andriy.gelman@gmail.com>
>
> Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
> ---
> libavformat/rtspdec.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
> index 1ff84cdd56..5a383b5a19 100644
> --- a/libavformat/rtspdec.c
> +++ b/libavformat/rtspdec.c
> @@ -694,12 +694,13 @@ static int rtsp_listen(AVFormatContext *s)
>         } else if (methodcode == SETUP)
>             ret = rtsp_read_setup(s, host, uri);
>         if (ret) {
> -            ffurl_close(rt->rtsp_hd);
>             ret = AVERROR_INVALIDDATA;
>             goto fail;
>         }
>     }
> fail:
> +    ff_rtsp_close_streams(s);
> +    ff_rtsp_close_connections(s);
>     ff_network_close();
>     return ret;
> }
> -- 
> 2.28.0

Looks ok, assuming that the error codepath has been tested.

// Martin
diff mbox series

Patch

diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c
index 1ff84cdd56..5a383b5a19 100644
--- a/libavformat/rtspdec.c
+++ b/libavformat/rtspdec.c
@@ -694,12 +694,13 @@  static int rtsp_listen(AVFormatContext *s)
         } else if (methodcode == SETUP)
             ret = rtsp_read_setup(s, host, uri);
         if (ret) {
-            ffurl_close(rt->rtsp_hd);
             ret = AVERROR_INVALIDDATA;
             goto fail;
         }
     }
 fail:
+    ff_rtsp_close_streams(s);
+    ff_rtsp_close_connections(s);
     ff_network_close();
     return ret;
 }