aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2021-08-18 23:31:03 +0200
committerPaul B Mahol <onemda@gmail.com>2021-08-19 09:45:09 +0200
commit6d09de90d1a1544e47c959de58189df30de9cda8 (patch)
tree52c43c51c5dc5c1950ee2d7bfb29d0e553694f8c
parent835eb0a556d678dd65bb1978519c4d62d93c37c4 (diff)
downloadffmpeg-6d09de90d1a1544e47c959de58189df30de9cda8.tar.gz
avfilter/vf_paletteuse: fix some integer overflows
-rw-r--r--libavfilter/vf_paletteuse.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c
index 1f1e36ba8e..4b2144c6f9 100644
--- a/libavfilter/vf_paletteuse.c
+++ b/libavfilter/vf_paletteuse.c
@@ -380,9 +380,9 @@ static av_always_inline int get_dst_color_err(PaletteUseContext *s,
if (dstx < 0)
return dstx;
dstc = s->palette[dstx];
- *er = r - (dstc >> 16 & 0xff);
- *eg = g - (dstc >> 8 & 0xff);
- *eb = b - (dstc & 0xff);
+ *er = (int)r - (int)(dstc >> 16 & 0xff);
+ *eg = (int)g - (int)(dstc >> 8 & 0xff);
+ *eb = (int)b - (int)(dstc & 0xff);
return dstx;
}
@@ -597,8 +597,8 @@ static int cmp_##name(const void *pa, const void *pb) \
{ \
const struct color *a = pa; \
const struct color *b = pb; \
- return (a->value >> (8 * (3 - (pos))) & 0xff) \
- - (b->value >> (8 * (3 - (pos))) & 0xff); \
+ return (int)(a->value >> (8 * (3 - (pos))) & 0xff) \
+ - (int)(b->value >> (8 * (3 - (pos))) & 0xff); \
}
DECLARE_CMP_FUNC(a, 0)
@@ -704,7 +704,7 @@ static int colormap_insert(struct color_node *map,
/* get the two boxes this node creates */
box1 = box2 = *box;
box1.max[component-1] = node->val[component];
- box2.min[component-1] = node->val[component] + 1;
+ box2.min[component-1] = FFMIN(node->val[component] + 1, 255);
node_left_id = colormap_insert(map, color_used, nb_used, palette, trans_thresh, &box1);