diff options
author | Andriy Gelman <andriy.gelman@gmail.com> | 2020-11-26 19:37:21 -0500 |
---|---|---|
committer | Andriy Gelman <andriy.gelman@gmail.com> | 2020-11-28 12:27:53 -0500 |
commit | f3891430fc15cc8a1b7a16916030962e0a4d609c (patch) | |
tree | cc9a1640d9d1f47a8fd18baef41a0dfbd34f46ed /libavformat/rtspdec.c | |
parent | b0019b909be7a735b09f89207272294008ff2c0c (diff) | |
download | ffmpeg-f3891430fc15cc8a1b7a16916030962e0a4d609c.tar.gz |
avformat/rtspdec: fix potential mem leak in listen mode
Currently a repeating setup request (with the same stream id) will
simply overwrite rtp_handle/transport_priv without freeing the
resources first. This is fixed by closing the previous setup request.
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
Diffstat (limited to 'libavformat/rtspdec.c')
-rw-r--r-- | libavformat/rtspdec.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c index be11576913..221f44b20b 100644 --- a/libavformat/rtspdec.c +++ b/libavformat/rtspdec.c @@ -274,6 +274,17 @@ static int rtsp_read_setup(AVFormatContext *s, char* host, char *controlurl) rtsp_st = rt->rtsp_streams[streamid]; localport = rt->rtp_port_min; + /* check if the stream has already been setup */ + if (rtsp_st->transport_priv) { + if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RDT) + ff_rdt_parse_close(rtsp_st->transport_priv); + else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RTP) + ff_rtp_parse_close(rtsp_st->transport_priv); + rtsp_st->transport_priv = NULL; + } + if (rtsp_st->rtp_handle) + ffurl_closep(&rtsp_st->rtp_handle); + if (request.transports[0].lower_transport == RTSP_LOWER_TRANSPORT_TCP) { rt->lower_transport = RTSP_LOWER_TRANSPORT_TCP; if ((ret = ff_rtsp_open_transport_ctx(s, rtsp_st))) { |