]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/vble.c
Silicon Graphics Movie (.mv) demuxer
[ffmpeg] / libavcodec / vble.c
index 448006a0c3361318a790eaf1082b5b58460c8912..c8037bdb808ec9fdb1f33da82b1cb596e5dbf1c3 100644 (file)
@@ -29,6 +29,7 @@
 #include "avcodec.h"
 #include "dsputil.h"
 #include "get_bits.h"
+#include "internal.h"
 #include "mathops.h"
 
 typedef struct {
@@ -110,7 +111,7 @@ static void vble_restore_plane(VBLEContext *ctx, GetBitContext *gb, int plane,
     }
 }
 
-static int vble_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
+static int vble_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
                              AVPacket *avpkt)
 {
     VBLEContext *ctx = avctx->priv_data;
@@ -127,8 +128,13 @@ static int vble_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     if (pic->data[0])
         avctx->release_buffer(avctx, pic);
 
+    if (avpkt->size < 4 || avpkt->size - 4 > INT_MAX/8) {
+        av_log(avctx, AV_LOG_ERROR, "Invalid packet size\n");
+        return AVERROR_INVALIDDATA;
+    }
+
     /* Allocate buffer */
-    if (avctx->get_buffer(avctx, pic) < 0) {
+    if (ff_get_buffer(avctx, pic) < 0) {
         av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n");
         return AVERROR(ENOMEM);
     }
@@ -163,7 +169,7 @@ static int vble_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
         vble_restore_plane(ctx, &gb, 2, offset, width_uv, height_uv);
     }
 
-    *data_size = sizeof(AVFrame);
+    *got_frame       = 1;
     *(AVFrame *)data = *pic;
 
     return avpkt->size;