mirror of
https://github.com/mpv-player/mpv
synced 2024-09-09 01:16:56 +02:00
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
This commit is contained in:
parent
4533ea0d55
commit
a5e9d3b56a
7
spudec.c
7
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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user