summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanne Grunau <janne-libav@jannau.net>2012-07-02 10:46:39 +0200
committerAnton Khirnov <anton@khirnov.net>2012-10-06 10:34:11 +0200
commit7296a6b5e9c22be515f7bd60a3c6c293691de3f8 (patch)
tree9c373fb1767a0750402a89f21e32102d99bf8c3f
parentf695be22d89aab1e0549e6ef04b1431c7db96316 (diff)
downloadffmpeg-7296a6b5e9c22be515f7bd60a3c6c293691de3f8.tar.gz
imgconvert: avoid undefined left shift in avcodec_find_best_pix_fmt
CC: libav-stable@libav.org (cherry picked from commit 39bb27bf79bc4c2d8beaed637a14176264cb1916) Signed-off-by: Anton Khirnov <anton@khirnov.net> (cherry picked from commit 7a7229b52d1900279041991fadbd29b27e8dfe95) Signed-off-by: Anton Khirnov <anton@khirnov.net> (cherry picked from commit 8812b5f164109553f009ce385e17a1af16b6ea53) Signed-off-by: Anton Khirnov <anton@khirnov.net> (cherry picked from commit fd7426ed898533bed98e6b472ff5f5c8e47f2eb5) Signed-off-by: Anton Khirnov <anton@khirnov.net>
-rw-r--r--libavcodec/imgconvert.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index 1e0c66de84..eecd12535e 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -890,7 +890,8 @@ static int avcodec_find_best_pix_fmt1(int64_t pix_fmt_mask,
/* find exact color match with smallest size */
dst_pix_fmt = -1;
min_dist = 0x7fffffff;
- for(i = 0;i < PIX_FMT_NB; i++) {
+ /* test only the first 64 pixel formats to avoid undefined behaviour */
+ for (i = 0; i < 64; i++) {
if (pix_fmt_mask & (1ULL << i)) {
loss = avcodec_get_pix_fmt_loss(i, src_pix_fmt, has_alpha) & loss_mask;
if (loss == 0) {