Merge "Snap for 4526935 from 9ca83ea75d0ad69d7ea57bcddd4af1e422f0b978 to oreo-mr1-cts-release" into oreo-mr1-cts-release
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 @@
 
 /**
  * \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];
 }
 
 
diff --git a/libSBRdec/src/lpp_tran.cpp b/libSBRdec/src/lpp_tran.cpp
index 117e739..343aec3 100644
--- a/libSBRdec/src/lpp_tran.cpp
+++ b/libSBRdec/src/lpp_tran.cpp
@@ -293,7 +293,7 @@
   }
 
   /* init bwIndex for each patch */
-  FDKmemclear(bwIndex, pSettings->noOfPatches*sizeof(INT));
+  FDKmemclear(bwIndex, MAX_NUM_PATCHES*sizeof(INT));
 
   /*
     Calc common low band scale factor
@@ -621,9 +621,9 @@
       FDK_ASSERT( hiBand < (64) );
 
       /* bwIndex[patch] is already initialized with value from previous band inside this patch */
-      while (hiBand >= pSettings->bwBorders[bwIndex[patch]])
+      while (hiBand >= pSettings->bwBorders[bwIndex[patch]] && bwIndex[patch] < MAX_NUM_PATCHES-1) {
         bwIndex[patch]++;
-
+      }
 
       /*
         Filter Step 2: add the left slope with the current filter to the buffer
@@ -962,6 +962,10 @@
   for(i = 0 ; i < noNoiseBands; i++){
     pSettings->bwBorders[i] = noiseBandTable[i+1];
   }
+  for (;i < MAX_NUM_NOISE_VALUES; i++) {
+    pSettings->bwBorders[i] = 255;
+  }
+
 
   /*
    * Choose whitening factors