diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-04-03 17:03:38 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-05-25 13:11:36 +0200 |
commit | 82bf41f3abce4a13e7c6ad1606eb708f371de87f (patch) | |
tree | a76e1dc947a8b2db0dbf821d5c8fcc5e61269a52 /libavformat/smoothstreamingenc.c | |
parent | af97c9865fe7a48b223e162eabce21cc180f305c (diff) |
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/smoothstreamingenc.c')
-rw-r--r-- | libavformat/smoothstreamingenc.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c index d10d5d1444..33bb404f46 100644 --- a/libavformat/smoothstreamingenc.c +++ b/libavformat/smoothstreamingenc.c @@ -99,14 +99,9 @@ static int64_t ism_seek(void *opaque, int64_t offset, int whence) if (whence != SEEK_SET) return AVERROR(ENOSYS); if (os->tail_out) { - if (os->out) { - ffurl_close(os->out); - } - if (os->out2) { - ffurl_close(os->out2); - } + ffurl_closep(&os->out); + ffurl_closep(&os->out2); os->out = os->tail_out; - os->out2 = NULL; os->tail_out = NULL; } if (offset >= os->cur_start_pos) { @@ -175,10 +170,9 @@ static void ism_free(AVFormatContext *s) return; for (i = 0; i < s->nb_streams; i++) { OutputStream *os = &c->streams[i]; - ffurl_close(os->out); - ffurl_close(os->out2); - ffurl_close(os->tail_out); - os->out = os->out2 = os->tail_out = NULL; + ffurl_closep(&os->out); + ffurl_closep(&os->out2); + ffurl_closep(&os->tail_out); if (os->ctx && os->ctx_inited) av_write_trailer(os->ctx); if (os->ctx && os->ctx->pb) @@ -537,8 +531,7 @@ static int ism_flush(AVFormatContext *s, int final) if (!os->out || os->tail_out) return AVERROR(EIO); - ffurl_close(os->out); - os->out = NULL; + ffurl_closep(&os->out); size = os->tail_pos - os->cur_start_pos; if ((ret = parse_fragment(s, filename, &start_ts, &duration, &moof_size, size)) < 0) break; |