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
commita1deac7b1a7034b8ee05a0390f5845a382ada01d (patch)
tree442735a9cd9bf28a587c0ecb853bc80ffb9823b2
parent9000e05228a100873606bfc4d758a2390b3eab1d (diff)
parent3b6a14a1e00e0f42bb31a17b7351c184422e595d (diff)
downloadfdk-aac-a1deac7b1a7034b8ee05a0390f5845a382ada01d.tar.gz
fdk-aac-a1deac7b1a7034b8ee05a0390f5845a382ada01d.tar.bz2
fdk-aac-a1deac7b1a7034b8ee05a0390f5845a382ada01d.zip
DO NOT MERGE Prevent out of bound memory access in GetInvInt
am: 3b6a14a1e0 Change-Id: Id527e5320a362042ef0c65329082a369687e9db7
-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 0d50f0a..6aa0a90 100644
--- a/libFDK/include/fixpoint_math.h
+++ b/libFDK/include/fixpoint_math.h
@@ -479,15 +479,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 80.
+ * input values from 0 upto 79.
* \param intValue Integer input value.
* \param FIXP_DBL representation of 1/intValue
*/
inline FIXP_DBL GetInvInt(int intValue)
{
- FDK_ASSERT((intValue > 0) && (intValue < 80));
- FDK_ASSERT(intValue<80);
- return invCount[intValue];
+ FDK_ASSERT((intValue >= 0) && (intValue < 80));
+ if (intValue > 79)
+ return invCount[79];
+ else if (intValue < 0)
+ return invCount[0];
+ else
+ return invCount[intValue];
}