diff mbox series

[FFmpeg-devel,16/17] avformat/webm_chunk: Check unchecked functions for errors

Message ID 20200302044445.14842-12-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/17] avformat: Use correct error in case muxer is not found
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andreas Rheinhardt March 2, 2020, 4:44 a.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/webm_chunk.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c
index 6ffe952eff..8f1f884c98 100644
--- a/libavformat/webm_chunk.c
+++ b/libavformat/webm_chunk.c
@@ -95,7 +95,8 @@  static int webm_chunk_init(AVFormatContext *s)
 
     oc->flush_packets         = 0;
 
-    av_dict_copy(&oc->metadata, s->metadata, 0);
+    if ((ret = av_dict_copy(&oc->metadata, s->metadata, 0)) < 0)
+        return ret;
 
     if (!(st = avformat_new_stream(oc, NULL)))
         return AVERROR(ENOMEM);
@@ -109,11 +110,14 @@  static int webm_chunk_init(AVFormatContext *s)
     avpriv_set_pts_info(st, ost->pts_wrap_bits, ost->time_base.num,
                                                 ost->time_base.den);
 
-    av_dict_set_int(&dict, "dash", 1, 0);
-    av_dict_set_int(&dict, "cluster_time_limit", wc->chunk_duration, 0);
-    av_dict_set_int(&dict, "live", 1, 0);
+    if ((ret = av_dict_set_int(&dict, "dash", 1, 0))   < 0 ||
+        (ret = av_dict_set_int(&dict, "cluster_time_limit",
+                               wc->chunk_duration, 0)) < 0 ||
+        (ret = av_dict_set_int(&dict, "live", 1, 0))   < 0)
+        goto fail;
 
     ret = avformat_init_output(oc, &dict);
+fail:
     av_dict_free(&dict);
     if (ret < 0)
         return ret;
@@ -155,7 +159,8 @@  static int webm_chunk_write_header(AVFormatContext *s)
     AVDictionary *options = NULL;
 
     if (wc->http_method)
-        av_dict_set(&options, "method", wc->http_method, 0);
+        if ((ret = av_dict_set(&options, "method", wc->http_method, 0)) < 0)
+            return ret;
     ret = s->io_open(s, &oc->pb, oc->url, AVIO_FLAG_WRITE, &options);
     av_dict_free(&options);
     if (ret < 0)
@@ -205,14 +210,15 @@  static int chunk_end(AVFormatContext *s, int flush)
     if (ret < 0)
         goto fail;
     if (wc->http_method)
-        av_dict_set(&options, "method", wc->http_method, 0);
+        if ((ret = av_dict_set(&options, "method", wc->http_method, 0)) < 0)
+            goto fail;
     ret = s->io_open(s, &pb, filename, AVIO_FLAG_WRITE, &options);
+    av_dict_free(&options);
     if (ret < 0)
         goto fail;
     avio_write(pb, buffer, buffer_size);
     ff_format_io_close(s, &pb);
 fail:
-    av_dict_free(&options);
     av_free(buffer);
     return (ret < 0) ? ret : 0;
 }
@@ -260,7 +266,9 @@  static int webm_chunk_write_trailer(AVFormatContext *s)
         if (ret < 0)
             return ret;
     }
-    av_write_trailer(oc);
+    ret = av_write_trailer(oc);
+    if (ret < 0)
+        return ret;
     return chunk_end(s, 0);
 }