Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 235684f2 authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge "Fix for integer over flow in LVPSA_process in libeffects"

parents a2cfcba3 e92cb6f8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -94,6 +94,7 @@ typedef uint16_t LVM_UINT16; /* Unsigned 16-bit word */

typedef     int32_t             LVM_INT32;          /* Signed 32-bit word */
typedef     uint32_t            LVM_UINT32;         /* Unsigned 32-bit word */
typedef     int64_t             LVM_INT64;          /* Signed 64-bit word */

#ifdef BUILD_FLOAT

+15 −4
Original line number Diff line number Diff line
@@ -22,6 +22,17 @@

#define LVM_MININT_32   0x80000000

static LVM_INT32 mult32x32in32_shiftr(LVM_INT32 a, LVM_INT32 b, LVM_INT32 c) {
  LVM_INT64 result = ((LVM_INT64)a * b) >> c;

  if (result >= INT32_MAX) {
    return INT32_MAX;
  } else if (result <= INT32_MIN) {
    return INT32_MIN;
  } else {
    return (LVM_INT32)result;
  }
}

/************************************************************************************/
/*                                                                                  */
@@ -123,10 +134,10 @@ LVPSA_RETURN LVPSA_Process ( pLVPSA_Handle_t hInstance,

    if(pLVPSA_Inst->pSpectralDataBufferWritePointer != pWrite_Save)
    {
        MUL32x32INTO32((AudioTime + (LVM_INT32)((LVM_INT32)pLVPSA_Inst->LocalSamplesCount*1000)),
        AudioTimeInc = mult32x32in32_shiftr(
                (AudioTime + ((LVM_INT32)pLVPSA_Inst->LocalSamplesCount * 1000)),
                (LVM_INT32)LVPSA_SampleRateInvTab[pLVPSA_Inst->CurrentParams.Fs],
                        AudioTimeInc,
                        LVPSA_FsInvertShift)
                LVPSA_FsInvertShift);
        pLVPSA_Inst->SpectralDataBufferAudioTime = AudioTime + AudioTimeInc;
    }