From 25fb9adf6fe129e0b74fe78c04526a57b8210f29 Mon Sep 17 00:00:00 2001 From: Fraunhofer IIS FDK Date: Wed, 13 Nov 2019 16:05:46 +0100 Subject: Avoid signed integer overflows in SpatialDecApplyParameterSets() when adding dry and wet signal. Bug: 146936964 Test: atest DecoderTestXheAac ; atest DecoderTestAacDrc Change-Id: Idb4242d54b2e61805ab071a8977eed8f06081edf --- libSACdec/src/sac_dec.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'libSACdec/src') diff --git a/libSACdec/src/sac_dec.cpp b/libSACdec/src/sac_dec.cpp index 3f55a7d..c1832f1 100644 --- a/libSACdec/src/sac_dec.cpp +++ b/libSACdec/src/sac_dec.cpp @@ -1317,10 +1317,12 @@ static SACDEC_ERROR SpatialDecApplyParameterSets( if ((self->tempShapeConfig == 1) && (!isTwoChMode(self->upmixType))) { for (ch = 0; ch < self->numOutputChannels; ch++) { for (hyb = 0; hyb < self->tp_hybBandBorder; hyb++) { - self->hybOutputRealDry__FDK[ch][hyb] += - self->hybOutputRealWet__FDK[ch][hyb]; - self->hybOutputImagDry__FDK[ch][hyb] += - self->hybOutputImagWet__FDK[ch][hyb]; + self->hybOutputRealDry__FDK[ch][hyb] = + fAddSaturate(self->hybOutputRealDry__FDK[ch][hyb], + self->hybOutputRealWet__FDK[ch][hyb]); + self->hybOutputImagDry__FDK[ch][hyb] = + fAddSaturate(self->hybOutputImagDry__FDK[ch][hyb], + self->hybOutputImagWet__FDK[ch][hyb]); } /* loop hyb */ } /* loop ch */ err = subbandTPApply( @@ -1341,11 +1343,11 @@ static SACDEC_ERROR SpatialDecApplyParameterSets( FIXP_DBL *RESTRICT pRealWet = self->hybOutputRealWet__FDK[ch]; FIXP_DBL *RESTRICT pImagWet = self->hybOutputImagWet__FDK[ch]; for (hyb = 0; hyb < nHybBands; hyb++) { - pRealDry[hyb] += pRealWet[hyb]; - pImagDry[hyb] += pImagWet[hyb]; + pRealDry[hyb] = fAddSaturate(pRealDry[hyb], pRealWet[hyb]); + pImagDry[hyb] = fAddSaturate(pImagDry[hyb], pImagWet[hyb]); } /* loop hyb */ for (; hyb < self->hybridBands; hyb++) { - pRealDry[hyb] += pRealWet[hyb]; + pRealDry[hyb] = fAddSaturate(pRealDry[hyb], pRealWet[hyb]); } /* loop hyb */ } /* loop ch */ } /* ( self->tempShapeConfig == 1 ) || ( self->tempShapeConfig == 2 ) */ -- cgit v1.2.3