# HG changeset patch # User reimar # Date 1280007606 0 # Node ID 8e850ff84b27fea79c180bd36ebe300c2a1bae32 # Parent 2e98a0ed97c80f9bffd1e9d580bcf440bd11b400 Allocate memory for paletted image data separately to avoid issues with e.g. the "cut" function. diff -r 2e98a0ed97c8 -r 8e850ff84b27 spudec.c --- a/spudec.c Sat Jul 24 21:34:13 2010 +0000 +++ b/spudec.c Sat Jul 24 21:40:06 2010 +0000 @@ -228,13 +228,15 @@ 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 @@ free(spu->scaled_image); if (spu->image) free(spu->image); + free(spu->pal_image); free(spu); } }