[MPlayer-cvslog] r31791 - trunk/spudec.c

reimar subversion at mplayerhq.hu
Sat Jul 24 23:40:06 CEST 2010


Author: reimar
Date: Sat Jul 24 23:40:06 2010
New Revision: 31791

Log:
Allocate memory for paletted image data separately to avoid
issues with e.g. the "cut" function.

Modified:
   trunk/spudec.c

Modified: trunk/spudec.c
==============================================================================
--- trunk/spudec.c	Sat Jul 24 23:34:13 2010	(r31790)
+++ trunk/spudec.c	Sat Jul 24 23:40:06 2010	(r31791)
@@ -228,13 +228,15 @@ static int spudec_alloc_image(spudec_han
   if (this->image_size < this->stride * this->height) {
     if (this->image != NULL) {
       free(this->image);
+      free(this->pal_image);
       this->image_size = 0;
     }
-    this->image = malloc(3 * this->stride * this->height);
+    this->image = malloc(2 * this->stride * this->height);
     if (this->image) {
       this->image_size = this->stride * this->height;
       this->aimage = this->image + this->image_size;
-      this->pal_image = this->aimage + this->image_size;
+      // use stride here as well to simplify reallocation checks
+      this->pal_image = malloc(this->stride * this->height);
     }
   }
   return this->image != NULL;
@@ -1269,6 +1271,7 @@ void spudec_free(void *this)
 	free(spu->scaled_image);
     if (spu->image)
       free(spu->image);
+    free(spu->pal_image);
     free(spu);
   }
 }


More information about the MPlayer-cvslog mailing list