summaryrefslogtreecommitdiff
path: root/libavutil/common.h
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2016-01-14 01:15:22 +0100
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2016-01-15 00:32:54 +0100
commitf8bc0137bdf8da8806ef75d30bb749fcc301bb35 (patch)
treeb86e92165b8a6115b55c2280e4007f8e911a3c1d /libavutil/common.h
parent2e4fd16f5b9084b86e6872fddc365d0528383259 (diff)
lavu: prevent overflow in av_clip_intp2_c
This fixes ubsan runtime error: signed integer overflow: 8388608 + 2140274688 cannot be represented in type 'int' Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Diffstat (limited to 'libavutil/common.h')
-rw-r--r--libavutil/common.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/libavutil/common.h b/libavutil/common.h
index f9766adaec..7b7bcbe8f3 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -211,7 +211,7 @@ static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
*/
static av_always_inline av_const int av_clip_intp2_c(int a, int p)
{
- if ((a + (1 << p)) & ~((2 << p) - 1))
+ if (((unsigned)a + (1 << p)) & ~((2 << p) - 1))
return (a >> 31) ^ ((1 << p) - 1);
else
return a;