]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/4xm.c
Fix imgresample-test compilation.
[ffmpeg] / libavcodec / 4xm.c
index 3ca2338d243f28c345ece6b29fdad79c2a72e511..36de40bff4e5fe83449af7a6be3beff5fcf1af1c 100644 (file)
@@ -104,8 +104,8 @@ static VLC block_type_vlc[4];
 
 
 typedef struct CFrameBuffer{
-    int allocated_size;
-    int size;
+    unsigned int allocated_size;
+    unsigned int size;
     int id;
     uint8_t *data;
 }CFrameBuffer;
@@ -606,7 +606,7 @@ static int decode_frame(AVCodecContext *avctx,
     int i, frame_4cc, frame_size;
 
     frame_4cc= get32(buf);
-    if(buf_size != get32(buf+4)+8){
+    if(buf_size != get32(buf+4)+8 || buf_size < 20){
         av_log(f->avctx, AV_LOG_ERROR, "size mismatch %d %d\n", buf_size, get32(buf+4));
     }
 
@@ -634,6 +634,10 @@ static int decode_frame(AVCodecContext *avctx,
         cfrm= &f->cfrm[i];
 
         cfrm->data= av_fast_realloc(cfrm->data, &cfrm->allocated_size, cfrm->size + data_size + FF_INPUT_BUFFER_PADDING_SIZE);
+        if(!cfrm->data){ //explicit check needed as memcpy below might not catch a NULL
+            av_log(f->avctx, AV_LOG_ERROR, "realloc falure");
+            return -1;
+        }
 
         memcpy(cfrm->data + cfrm->size, buf+20, data_size);
         cfrm->size += data_size;