aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/intmath.h
diff options
context:
space:
mode:
authorTomas Härdin <git@haerdin.se>2024-05-16 18:10:58 +0200
committerTomas Härdin <git@haerdin.se>2024-06-14 14:28:25 +0200
commitbe2cabce327b58a549500bbeb3a342530f2573e9 (patch)
tree3c4f452d81ba2e137e4ad353529adb22a5dfe11d /libavutil/intmath.h
parent3b9e457647a3c8554e32edf2e2effb11280ddda7 (diff)
downloadffmpeg-be2cabce327b58a549500bbeb3a342530f2573e9.tar.gz
lavu/intmath.h: Fix UB in ff_ctz_c() and ff_ctzll_c()
Found by value analysis
Diffstat (limited to 'libavutil/intmath.h')
-rw-r--r--libavutil/intmath.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/libavutil/intmath.h b/libavutil/intmath.h
index c54d23b7bf..52e11a8d5f 100644
--- a/libavutil/intmath.h
+++ b/libavutil/intmath.h
@@ -119,7 +119,7 @@ static av_always_inline av_const int ff_ctz_c(int v)
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
};
- return debruijn_ctz32[(uint32_t)((v & -v) * 0x077CB531U) >> 27];
+ return debruijn_ctz32[(uint32_t)((v & -(uint32_t)v) * 0x077CB531U) >> 27];
}
#endif
@@ -135,7 +135,7 @@ static av_always_inline av_const int ff_ctzll_c(long long v)
63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12
};
- return debruijn_ctz64[(uint64_t)((v & -v) * 0x022FDD63CC95386DU) >> 58];
+ return debruijn_ctz64[(uint64_t)((v & -(uint64_t)v) * 0x022FDD63CC95386DU) >> 58];
}
#endif