changeset 35256:4ca7b3dfb574

Fix crash when not able to find a mpi by using an early return.
author reimar
date Mon, 05 Nov 2012 20:58:38 +0000
parents c93bf3f1540b
children 9a46ec65165d
files libmpcodecs/vf.c
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf.c	Mon Nov 05 20:53:49 2012 +0000
+++ b/libmpcodecs/vf.c	Mon Nov 05 20:58:38 2012 +0000
@@ -279,6 +279,7 @@
   mp_image_t* mpi=NULL;
   int w2;
   int number = (mp_imgtype >> 16) - 1;
+  int missing_palette;
 
 #ifdef MP_DEBUG
   assert(w == -1 || w >= vf->w);
@@ -344,8 +345,10 @@
     mpi->number = number;
     break;
   }
-  if(mpi){
-    int missing_palette = !(mpi->flags & MP_IMGFLAG_RGB_PALETTE) && (mp_imgflag & MP_IMGFLAG_RGB_PALETTE);
+
+  if (!mpi)
+    return NULL;
+
     mpi->type=mp_imgtype;
     mpi->w=vf->w; mpi->h=vf->h;
     // keep buffer allocation status & color flags only:
@@ -354,6 +357,7 @@
     // accept restrictions, draw_slice and palette flags only:
     mpi->flags|=mp_imgflag&(MP_IMGFLAGMASK_RESTRICTIONS|MP_IMGFLAG_DRAW_CALLBACK|MP_IMGFLAG_RGB_PALETTE);
     if(!vf->draw_slice) mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
+    missing_palette = !(mpi->flags & MP_IMGFLAG_RGB_PALETTE) && (mp_imgflag & MP_IMGFLAG_RGB_PALETTE);
     if(mpi->width!=w2 || mpi->height!=h || missing_palette){
 //      printf("vf.c: MPI parameters changed!  %dx%d -> %dx%d   \n", mpi->width,mpi->height,w2,h);
         if(mpi->flags&MP_IMGFLAG_ALLOCATED){
@@ -429,7 +433,6 @@
     }
 
   mpi->qscale = NULL;
-  }
   mpi->usage_count++;
   // TODO: figure out what is going on with EXPORT types
   if (mpi->usage_count > 1 && mpi->type != MP_IMGTYPE_EXPORT)