Patchwork [04/48] audio: fix integer overflow expression

login
register
mail settings
Submitter Riku Voipio
Date March 26, 2010, 4:06 p.m.
Message ID <cacba09517ce681b93a115016d8311d63d77452c.1269617186.git.riku.voipio@nokia.com>
Download mbox | patch
Permalink /patch/48703/
State New
Headers show

Comments

Riku Voipio - March 26, 2010, 4:06 p.m.
From: Juha Riihimäki <juha.riihimaki@nokia.com>

Signed-Off-By: Riku Voipio <riku.voipio@nokia.com>
Signed-Off-By: Juha Riihimäki <juha.riihimaki@nokia.com>

---
 audio/mixeng_template.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/audio/mixeng_template.h b/audio/mixeng_template.h
index 5617705..80af364 100644
--- a/audio/mixeng_template.h
+++ b/audio/mixeng_template.h
@@ -56,7 +56,7 @@  static mixeng_real inline glue (conv_, ET) (IN_T v)
 #endif
 #else  /* !RECIPROCAL */
 #ifdef SIGNED
-    return nv / (mixeng_real) (IN_MAX - IN_MIN);
+    return nv / (mixeng_real) ((mixeng_real)IN_MAX - (mixeng_real)IN_MIN);
 #else
     return (nv - HALF) / (mixeng_real) IN_MAX;
 #endif
@@ -73,7 +73,7 @@  static IN_T inline glue (clip_, ET) (mixeng_real v)
     }
 
 #ifdef SIGNED
-    return ENDIAN_CONVERT ((IN_T) (v * (IN_MAX - IN_MIN)));
+    return ENDIAN_CONVERT ((IN_T) (v * ((mixeng_real)IN_MAX - (mixeng_real)IN_MIN)));
 #else
     return ENDIAN_CONVERT ((IN_T) ((v * IN_MAX) + HALF));
 #endif