Commit 436206c1 authored by Michael Niedermayer's avatar Michael Niedermayer

avcodec/webp: add assert to ensure palette is not larger than 256

it should not be possible to be larger as its stored as 8bit value
but we would be overwriting a stack buffer if it is ...
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 19fb4768
...@@ -1065,6 +1065,7 @@ static int apply_color_indexing_transform(WebPContext *s) ...@@ -1065,6 +1065,7 @@ static int apply_color_indexing_transform(WebPContext *s)
if (img->frame->height * img->frame->width > 300) { if (img->frame->height * img->frame->width > 300) {
uint8_t palette[256 * 4]; uint8_t palette[256 * 4];
const int size = pal->frame->width * 4; const int size = pal->frame->width * 4;
av_assert0(size <= 1024U);
memcpy(palette, GET_PIXEL(pal->frame, 0, 0), size); // copy palette memcpy(palette, GET_PIXEL(pal->frame, 0, 0), size); // copy palette
// set extra entries to transparent black // set extra entries to transparent black
memset(palette + size, 0, 256 * 4 - size); memset(palette + size, 0, 256 * 4 - size);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment