avcodec/h264_mp4toannexb_bsf: Reorder operations in nal_size check
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 21 Aug 2015 00:49:21 +0000 (02:49 +0200)
committerCarl Eugen Hoyos <cehoyos@ag.or.at>
Fri, 9 Oct 2015 23:15:12 +0000 (01:15 +0200)
Fixes Ticket4778

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2bb54b82b5094fd906aa28c0443be08c95662a31)

libavcodec/h264_mp4toannexb_bsf.c

index 975e6e5..2f005f2 100644 (file)
@@ -168,7 +168,7 @@ static int h264_mp4toannexb_filter(AVBitStreamFilterContext *bsfc,
         buf      += ctx->length_size;
         unit_type = *buf & 0x1f;
 
-        if (buf + nal_size > buf_end || nal_size < 0)
+        if (nal_size > buf_end - buf || nal_size < 0)
             goto fail;
 
         /* prepend only to the first type 5 NAL unit of an IDR picture */