aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2017-11-03 19:13:34 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-11-03 19:13:34 +0000
commit96fbbc31db5359a3608c73139f8e00e469cdf6c9 (patch)
tree23d80c3b7ee8db1ebe5603fd7be50033edbdd2f0
parent0cf3a7671ad40c1036387d55462f1710a44eec31 (diff)
parent6fac7101c680741bd2cf763ce8ed7c16fd169321 (diff)
downloadfdk-aac-96fbbc31db5359a3608c73139f8e00e469cdf6c9.tar.gz
fdk-aac-96fbbc31db5359a3608c73139f8e00e469cdf6c9.tar.bz2
fdk-aac-96fbbc31db5359a3608c73139f8e00e469cdf6c9.zip
DO NOT MERGE Prevent out of bound memory access in GetInvInt am: 070e7b81c0
am: 6fac7101c6 Change-Id: If3c68bd6341d7c9eff5257ec41ca6c1a2161077c
-rw-r--r--libFDK/include/fixpoint_math.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/libFDK/include/fixpoint_math.h b/libFDK/include/fixpoint_math.h
index df141d3..26c001f 100644
--- a/libFDK/include/fixpoint_math.h
+++ b/libFDK/include/fixpoint_math.h
@@ -450,15 +450,19 @@ inline FIXP_DBL fAddSaturate(const FIXP_DBL a, const FIXP_DBL b)
/**
* \brief Calculate the value of 1/i where i is a integer value. It supports
- * input values from 1 upto 50.
+ * input values from 0 upto 49.
* \param intValue Integer input value.
* \param FIXP_DBL representation of 1/intValue
*/
inline FIXP_DBL GetInvInt(int intValue)
{
- FDK_ASSERT((intValue > 0) && (intValue < 50));
- FDK_ASSERT(intValue<50);
- return invCount[intValue];
+ FDK_ASSERT((intValue >= 0) && (intValue < 50));
+ if (intValue < 0)
+ return invCount[0];
+ else if (intValue > 49)
+ return invCount[49];
+ else
+ return invCount[intValue];
}