summaryrefslogtreecommitdiff
path: root/libavformat/rtsp.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-04-03 17:03:38 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-05-25 13:11:36 +0200
commit82bf41f3abce4a13e7c6ad1606eb708f371de87f (patch)
treea76e1dc947a8b2db0dbf821d5c8fcc5e61269a52 /libavformat/rtsp.c
parentaf97c9865fe7a48b223e162eabce21cc180f305c (diff)
downloadffmpeg-82bf41f3abce4a13e7c6ad1606eb708f371de87f.tar.gz
avformat: Replace ffurl_close() by ffurl_closep() where appropriate
It avoids leaving dangling pointers behind in memory. Also remove redundant checks for whether the URLContext to be closed is already NULL. Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavformat/rtsp.c')
-rw-r--r--libavformat/rtsp.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index b2b3f32011..5d8491b74b 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -763,9 +763,7 @@ void ff_rtsp_undo_setup(AVFormatContext *s, int send_packets)
ff_rtp_parse_close(rtsp_st->transport_priv);
}
rtsp_st->transport_priv = NULL;
- if (rtsp_st->rtp_handle)
- ffurl_close(rtsp_st->rtp_handle);
- rtsp_st->rtp_handle = NULL;
+ ffurl_closep(&rtsp_st->rtp_handle);
}
}
@@ -1666,9 +1664,10 @@ fail:
void ff_rtsp_close_connections(AVFormatContext *s)
{
RTSPState *rt = s->priv_data;
- if (rt->rtsp_hd_out != rt->rtsp_hd) ffurl_close(rt->rtsp_hd_out);
- ffurl_close(rt->rtsp_hd);
- rt->rtsp_hd = rt->rtsp_hd_out = NULL;
+ if (rt->rtsp_hd_out != rt->rtsp_hd)
+ ffurl_closep(&rt->rtsp_hd_out);
+ rt->rtsp_hd_out = NULL;
+ ffurl_closep(&rt->rtsp_hd);
}
int ff_rtsp_connect(AVFormatContext *s)
@@ -2496,8 +2495,7 @@ static int rtp_read_header(AVFormatContext *s)
break;
}
getsockname(ffurl_get_file_handle(in), (struct sockaddr*) &addr, &addrlen);
- ffurl_close(in);
- in = NULL;
+ ffurl_closep(&in);
par = avcodec_parameters_alloc();
if (!par) {
@@ -2571,8 +2569,7 @@ fail_nobuf:
av_bprint_finalize(&sdp, NULL);
fail:
avcodec_parameters_free(&par);
- if (in)
- ffurl_close(in);
+ ffurl_closep(&in);
ff_network_close();
return ret;
}