Merge "Add QMF analysis band sanity check"
am: b30e02cfd3

Change-Id: I6f21f18ac59f27eecdddb37d81bdfacf34cbae38
diff --git a/libAACdec/src/aacdecoder_lib.cpp b/libAACdec/src/aacdecoder_lib.cpp
index cbcd404..c214ba1 100644
--- a/libAACdec/src/aacdecoder_lib.cpp
+++ b/libAACdec/src/aacdecoder_lib.cpp
@@ -1398,9 +1398,13 @@
         mpegSurroundDecoder_ConfigureQmfDomain(
             (CMpegSurroundDecoder *)self->pMpegSurroundDecoder, sac_interface,
             (UINT)self->streamInfo.aacSampleRate, self->streamInfo.aot);
-        self->qmfDomain.globalConf.nQmfTimeSlots_requested =
-            self->streamInfo.aacSamplesPerFrame /
-            self->qmfDomain.globalConf.nBandsAnalysis_requested;
+        if (self->qmfDomain.globalConf.nBandsAnalysis_requested > 0) {
+          self->qmfDomain.globalConf.nQmfTimeSlots_requested =
+              self->streamInfo.aacSamplesPerFrame /
+              self->qmfDomain.globalConf.nBandsAnalysis_requested;
+        } else {
+          self->qmfDomain.globalConf.nQmfTimeSlots_requested = 0;
+        }
       }
 
       self->qmfDomain.globalConf.TDinput = pTimeData;
diff --git a/libSACdec/src/sac_dec_lib.cpp b/libSACdec/src/sac_dec_lib.cpp
index 5792858..bf6dedf 100644
--- a/libSACdec/src/sac_dec_lib.cpp
+++ b/libSACdec/src/sac_dec_lib.cpp
@@ -1658,6 +1658,10 @@
   initControlFlags = controlFlags;
 
   /* Check that provided output buffer is large enough. */
+  if (pMpegSurroundDecoder->pQmfDomain->globalConf.nBandsAnalysis == 0) {
+    err = MPS_UNSUPPORTED_FORMAT;
+    goto bail;
+  }
   timeDataRequiredSize =
       (timeDataFrameSize *
        pMpegSurroundDecoder->pSpatialDec->numOutputChannelsAT *