From 644bff6c9bf15b5ed723a893236dbc8c29579c93 Mon Sep 17 00:00:00 2001 From: Mans Rullgard Date: Fri, 25 Nov 2011 18:46:35 +0000 Subject: [PATCH] apedec: fix signed integer overflows This bit manipulation is equivalent but avoids undefined shifts and overflows. Signed-off-by: Mans Rullgard --- libavcodec/apedec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c index 6c3d29e..7702b29 100644 --- a/libavcodec/apedec.c +++ b/libavcodec/apedec.c @@ -690,7 +690,7 @@ static void do_apply_filter(APEContext *ctx, int version, APEFilter *f, /* Update the adaption coefficients */ absres = FFABS(res); if (absres) - *f->adaptcoeffs = ((res & (1<<31)) - (1<<30)) >> + *f->adaptcoeffs = ((res & (-1<<31)) ^ (-1<<30)) >> (25 + (absres <= f->avg*3) + (absres <= f->avg*4/3)); else *f->adaptcoeffs = 0; -- 2.7.4