[FFmpeg-devel] [PATCH] invalid array index(< 0)

Limin Wang lance.lmwang
Thu Oct 18 07:54:22 CEST 2007


Hi,

ff_find_unused_picture() may return -1 in case it can't get unused picture,
attached patch try to avoid visit invalid array pointer if error happend.


Thanks,
Limin
-------------- next part --------------
Index: libavcodec/mpegvideo.c
===================================================================
--- libavcodec/mpegvideo.c	(revision 10773)
+++ libavcodec/mpegvideo.c	(working copy)
@@ -904,6 +904,10 @@
             pic= (AVFrame*)s->current_picture_ptr; //we allready have a unused image (maybe it was set before reading the header)
         else{
             i= ff_find_unused_picture(s, 0);
+            if( i < 0 ) {
+                av_log(avctx, AV_LOG_ERROR, "can't find unused picture\n");
+                return -1;
+            }
             pic= (AVFrame*)&s->picture[i];
         }
 



More information about the ffmpeg-devel mailing list