summaryrefslogtreecommitdiffstats
path: root/spudec.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-07-24 21:40:06 +0000
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-02 04:14:45 +0200
commita5e9d3b56a82c2a2e1508f437a4890f6e4a1fc5c (patch)
tree506851259a7dc0e1d0bf85ca4333e6d3a75363a4 /spudec.c
parent4533ea0d55bd03905f2741b93912d58a9c7ffd0c (diff)
downloadmpv-a5e9d3b56a82c2a2e1508f437a4890f6e4a1fc5c.tar.bz2
mpv-a5e9d3b56a82c2a2e1508f437a4890f6e4a1fc5c.tar.xz
spudec: Allocate memory for paletted image data separately
Use a separate allocation to avoid issues with e.g. the "cut" function. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31791 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'spudec.c')
-rw-r--r--spudec.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/spudec.c b/spudec.c
index 6ac30c32c7..da665a8ddf 100644
--- a/spudec.c
+++ b/spudec.c
@@ -228,13 +228,15 @@ static int spudec_alloc_image(spudec_handle_t *this, int stride, int height)
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);
}
}