diff options
author | wm4 <wm4@nowhere> | 2015-07-05 23:55:47 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-07-05 23:55:47 +0200 |
commit | 34b223d730c97225accae4107a032c9b7ebf2194 (patch) | |
tree | a3d2b9c3169669efe848b6111a709a2b3b67db35 | |
parent | 95424517a2c9cf0873f3216865638a4ee7d5739a (diff) | |
download | mpv-34b223d730c97225accae4107a032c9b7ebf2194.tar.bz2 mpv-34b223d730c97225accae4107a032c9b7ebf2194.tar.xz |
mp_image: make image writeable before overwriting palette
This is an obscure but theoretically possible bug.
-rw-r--r-- | video/mp_image.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/video/mp_image.c b/video/mp_image.c index dc305a4b63..3816e297ad 100644 --- a/video/mp_image.c +++ b/video/mp_image.c @@ -364,8 +364,10 @@ void mp_image_copy_attributes(struct mp_image *dst, struct mp_image *src) } mp_image_params_guess_csp(&dst->params); // ensure colorspace consistency if ((dst->fmt.flags & MP_IMGFLAG_PAL) && (src->fmt.flags & MP_IMGFLAG_PAL)) { - if (dst->planes[1] && src->planes[1]) - memcpy(dst->planes[1], src->planes[1], MP_PALETTE_SIZE); + if (dst->planes[1] && src->planes[1]) { + if (mp_image_make_writeable(dst)) + memcpy(dst->planes[1], src->planes[1], MP_PALETTE_SIZE); + } } } |