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

Martin Storsjö martin at martin.st
Fri Nov 20 10:22:43 EET 2020


On Mon, 12 Oct 2020, Andriy Gelman wrote:

> From: Andriy Gelman <andriy.gelman at gmail.com>
>
> Signed-off-by: Andriy Gelman <andriy.gelman at 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



More information about the ffmpeg-devel mailing list