diff options
author | Andriy Gelman <andriy.gelman@gmail.com> | 2020-10-12 16:36:09 -0400 |
---|---|---|
committer | Andriy Gelman <andriy.gelman@gmail.com> | 2020-11-21 10:15:52 -0500 |
commit | 4fe9e2fc162a9d3258eb39dd16677970c657c122 (patch) | |
tree | c824e25130bc0f7e24804ad11e48b3b79e4849d6 /libavformat/rtsp.c | |
parent | 78537aa52f03f9fcf1f278c8bb8cc30ee1a64d38 (diff) | |
download | ffmpeg-4fe9e2fc162a9d3258eb39dd16677970c657c122.tar.gz |
avformat/rtsp: don't forget to call ff_network_close() on error
In sdp_read_header() some ff_network_close() calls were missed.
Also in rtp_read_header() update comment to explain why a single
call to ff_network_close() is enough to cover all cases even if
sdp_read_header() returns an error.
Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andriy Gelman <andriy.gelman@gmail.com>
Diffstat (limited to 'libavformat/rtsp.c')
-rw-r--r-- | libavformat/rtsp.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index b0631c7abf..0be405aba1 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -2337,11 +2337,14 @@ static int sdp_read_header(AVFormatContext *s) /* read the whole sdp file */ /* XXX: better loading */ content = av_malloc(SDP_MAX_SIZE); - if (!content) + if (!content) { + ff_network_close(); return AVERROR(ENOMEM); + } size = avio_read(s->pb, content, SDP_MAX_SIZE - 1); if (size <= 0) { av_free(content); + ff_network_close(); return AVERROR_INVALIDDATA; } content[size] ='\0'; @@ -2540,7 +2543,9 @@ static int rtp_read_header(AVFormatContext *s) ffio_init_context(&pb, sdp.str, sdp.len, 0, NULL, NULL, NULL, NULL); s->pb = &pb; - /* sdp_read_header initializes this again */ + /* if sdp_read_header() fails then following ff_network_close() cancels out */ + /* ff_network_init() at the start of this function. Otherwise it cancels out */ + /* ff_network_init() inside sdp_read_header() */ ff_network_close(); rt->media_type_mask = (1 << (AVMEDIA_TYPE_SUBTITLE+1)) - 1; |