提交 578c7b2c 编写于 作者: J Juha Riihim?ki 提交者: malc

audio: fix integer overflow expression

Fix an integer overflow that can happen for signed 32 bit types
when using FLOAT_MIXENG. (Note that at the moment this is only true
when using the MacOSX coreaudio audio driver.)
Signed-off-by: NJuha Riihim?ki <juha.riihimaki@nokia.com>
[Peter Maydell: Removed unnecessary casts]
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Signed-off-by: Nmalc <av1474@comtv.ru>
上级 b1d7d2b9
...@@ -46,7 +46,7 @@ static mixeng_real inline glue (conv_, ET) (IN_T v) ...@@ -46,7 +46,7 @@ static mixeng_real inline glue (conv_, ET) (IN_T v)
#endif #endif
#else /* !RECIPROCAL */ #else /* !RECIPROCAL */
#ifdef SIGNED #ifdef SIGNED
return nv / (mixeng_real) (IN_MAX - IN_MIN); return nv / (mixeng_real) ((mixeng_real) IN_MAX - IN_MIN);
#else #else
return (nv - HALF) / (mixeng_real) IN_MAX; return (nv - HALF) / (mixeng_real) IN_MAX;
#endif #endif
...@@ -63,7 +63,7 @@ static IN_T inline glue (clip_, ET) (mixeng_real v) ...@@ -63,7 +63,7 @@ static IN_T inline glue (clip_, ET) (mixeng_real v)
} }
#ifdef SIGNED #ifdef SIGNED
return ENDIAN_CONVERT ((IN_T) (v * (IN_MAX - IN_MIN))); return ENDIAN_CONVERT ((IN_T) (v * ((mixeng_real) IN_MAX - IN_MIN)));
#else #else
return ENDIAN_CONVERT ((IN_T) ((v * IN_MAX) + HALF)); return ENDIAN_CONVERT ((IN_T) ((v * IN_MAX) + HALF));
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册