[FFmpeg-cvslog] avformat/matroskaenc: Check functions that can fail

Andreas Rheinhardt git at videolan.org
Wed May 20 08:37:31 EEST 2020


ffmpeg | branch: release/4.2 | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Wed Jan  1 01:58:23 2020 +0100| [12efc04b3bfccd96edbc017855fbb6f330bb5c7b] | committer: Andreas Rheinhardt

avformat/matroskaenc: Check functions that can fail

Sometimes it has not been checked whether opening the dynamic buffer for
writing Tags fails; this might have led to segfaults.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit b4f300f8ea209b861865ef495b298a88b48f3913)

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=12efc04b3bfccd96edbc017855fbb6f330bb5c7b
---

 libavformat/matroskaenc.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index acc7090e77..41f84b1af9 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1578,7 +1578,9 @@ static int mkv_write_tag_targets(AVFormatContext *s, uint32_t elementid,
         ret = mkv_add_seekhead_entry(mkv->seekhead, MATROSKA_ID_TAGS, avio_tell(s->pb));
         if (ret < 0) return ret;
 
-        start_ebml_master_crc32(&mkv->tags_bc, mkv);
+        ret = start_ebml_master_crc32(&mkv->tags_bc, mkv);
+        if (ret < 0)
+            return ret;
     }
     pb = mkv->tags_bc;
 
@@ -1674,7 +1676,10 @@ static int mkv_write_tags(AVFormatContext *s)
             if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT)
                 continue;
 
-            mkv_write_tag_targets(s, MATROSKA_ID_TAGTARGETS_TRACKUID, i + 1, &tag_target);
+            ret = mkv_write_tag_targets(s, MATROSKA_ID_TAGTARGETS_TRACKUID,
+                                        i + 1, &tag_target);
+            if (ret < 0)
+                return ret;
             pb = mkv->tags_bc;
 
             tag = start_ebml_master(pb, MATROSKA_ID_SIMPLETAG, 0);



More information about the ffmpeg-cvslog mailing list