]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/truemotion2.c
lavc/vaapi_encode_h264: add "coder" option support
[ffmpeg] / libavcodec / truemotion2.c
index e6ae05f1d5fdfaf5bc3d32c2f2190119b00fbfca..a463a925fd49756127c845facf6bd13a0ea95da1 100644 (file)
@@ -298,15 +298,15 @@ static int tm2_read_stream(TM2Context *ctx, const uint8_t *buf, int stream_id, i
     /* get stream length in dwords */
     bytestream2_init(&gb, buf, buf_size);
     len  = bytestream2_get_be32(&gb);
-    skip = len * 4 + 4;
 
     if (len == 0)
         return 4;
 
-    if (len >= INT_MAX / 4 - 1 || len < 0 || skip > buf_size) {
+    if (len >= INT_MAX / 4 - 1 || len < 0 || len * 4 + 4 > buf_size) {
         av_log(ctx->avctx, AV_LOG_ERROR, "Error, invalid stream size.\n");
         return AVERROR_INVALIDDATA;
     }
+    skip = len * 4 + 4;
 
     toks = bytestream2_get_be32(&gb);
     if (toks & 1) {