[FFmpeg-devel] [PATCH] lavu: check for overflow in av_clip_intp2_c

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Wed Jan 13 00:52:21 CET 2016


---
 libavutil/common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/common.h b/libavutil/common.h
index f3276a2..5ae2847 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 (a >= INT_MAX - (1 << p) || ((a + (1 << p)) & ~((2 << p) - 1)))
         return (a >> 31) ^ ((1 << p) - 1);
     else
         return a;
-- 
2.6.4


More information about the ffmpeg-devel mailing list