From 29e4d6cf92ffb722a25adeafcb410cb7ea385ebe Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Fri, 4 May 2018 12:46:44 +0300 Subject: [PATCH] Fix overflows in accumulation, fixing crashes This fixes github issue #83. --- libSBRenc/src/tran_det.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libSBRenc/src/tran_det.cpp b/libSBRenc/src/tran_det.cpp index 0e35ec341..51d6efe60 100644 --- a/libSBRenc/src/tran_det.cpp +++ b/libSBRenc/src/tran_det.cpp @@ -256,12 +256,12 @@ static FIXP_DBL addLowbandEnergies(FIXP_DBL **Energies, /* freqBandTable[LORES] has MAX_FREQ_COEFFS/2 +1 coeefs max. */ for (ts=tran_offdiv2; ts> 6; + accu1 = fAddSaturate(accu1, Energies[ts][k] >> 6); } } for (; ts>nrgSzShift); ts++) { for (k = 0; k < freqBandTable[0]; k++) { - accu2 += Energies[ts][k] >> 9; + accu2 = fAddSaturate(accu2, Energies[ts][k] >> 9); } }