diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2017-11-03 19:10:04 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-11-03 19:10:04 +0000 |
commit | e64c50101367f780ec68da73bea8c9f31116ac5a (patch) | |
tree | 650e11f2a0ee25efa521dd51421d96fdcaa069ff /libFDK | |
parent | afe3b88936c7c2496b5e54129caae8efb63e64c4 (diff) | |
parent | 5ce724f1dda065f0e7cc4bfdd69a0bcdf31d0d98 (diff) | |
download | fdk-aac-e64c50101367f780ec68da73bea8c9f31116ac5a.tar.gz fdk-aac-e64c50101367f780ec68da73bea8c9f31116ac5a.tar.bz2 fdk-aac-e64c50101367f780ec68da73bea8c9f31116ac5a.zip |
DO NOT MERGE Prevent out of bound memory access in GetInvInt
am: 5ce724f1dd
Change-Id: I3b88b500ce26106a277ce6604c6d513bac4a7085
Diffstat (limited to 'libFDK')
-rw-r--r-- | libFDK/include/fixpoint_math.h | 12 |
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]; } |