[FFmpeg-cvslog] avformat/matroskaenc: Replace impossible condition with assert

Andreas Rheinhardt git at videolan.org
Sun May 3 14:33:10 EEST 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Tue Apr 28 02:24:16 2020 +0200| [ca0a38f2f7803ab8fa12913d0385d4c70f8d6345] | committer: Andreas Rheinhardt

avformat/matroskaenc: Replace impossible condition with assert

If a FLAC track uses an unconventional channel layout, the Matroska
muxer adds a WAVEFORMATEXTENSIBLE_CHANNEL_MASK VorbisComment to the
CodecPrivate to preserve this information. And given that FLAC uses
24bit length fields, the muxer checks if the length is more than this
and errors out if it is.

Yet this can never happen, because we create the AVDictionary that is
the source for the VorbisComment. It only contains exactly one entry
that can't grow infinitely large (in fact, the length of the
VorbisComment is <= 4 + 33 + 1 + 18 + strlen(LIBAVFORMAT_IDENT)).
So we can simply assert the size to be < (1 << 24) - 4.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

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

 libavformat/matroskaenc.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index f69b3c39da..87dff6ab7d 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -631,10 +631,7 @@ static int put_flac_codecpriv(AVFormatContext *s, AVIOContext *pb,
         av_dict_set(&dict, "WAVEFORMATEXTENSIBLE_CHANNEL_MASK", buf, 0);
 
         len = ff_vorbiscomment_length(dict, vendor, NULL, 0);
-        if (len >= (1 << 24) - 4) {
-            av_dict_free(&dict);
-            return AVERROR(EINVAL);
-        }
+        av_assert1(len < (1 << 24) - 4);
 
         data = av_malloc(len + 4);
         if (!data) {



More information about the ffmpeg-cvslog mailing list