[FFmpeg-cvslog] g723_1: fix overflow in square_root()

Michael Niedermayer git at videolan.org
Sun Oct 14 03:47:46 CEST 2012


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Oct 14 03:42:28 2012 +0200| [014b178f84fd6c5766e6a626a83f15a0dc635c90] | committer: Michael Niedermayer

g723_1: fix overflow in square_root()

the intermediate does not fit in a signed 32bit int

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=014b178f84fd6c5766e6a626a83f15a0dc635c90
---

 libavcodec/g723_1.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/g723_1.c b/libavcodec/g723_1.c
index 29eb4fa..017ecc4 100644
--- a/libavcodec/g723_1.c
+++ b/libavcodec/g723_1.c
@@ -226,8 +226,10 @@ static int unpack_bitstream(G723_1_Context *p, const uint8_t *buf,
 /**
  * Bitexact implementation of sqrt(val/2).
  */
-static int16_t square_root(int val)
+static int16_t square_root(unsigned val)
 {
+    av_assert2(!(val & 0x80000000));
+
     return (ff_sqrt(val << 1) >> 1) & (~1);
 }
 



More information about the ffmpeg-cvslog mailing list