From 101a71e03bbf860aaafb7090a0e440675cb27660 Mon Sep 17 00:00:00 2001
From: Jean-Marc Valin <jmvalin@jmvalin.ca>
Date: Fri, 11 Aug 2023 04:06:52 -0400
Subject: [PATCH] Fixes stack overflow for some custom modes

This only affects custom modes (builds with --enable-custom-modes) with frame
sizes 2.5, 5, 10, and 20ms and sampling rates below 40 kHz. The problem does
not affect normal use of Opus (using OpusEncoder/OpusDecoder) even when built
with custom modes enabled, but only special applications that use
OpusCustomEncoder/OpusCustomDecoder.
---
 celt/bands.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/celt/bands.c b/celt/bands.c
index 5320ffab0..6785e08e0 100644
--- a/celt/bands.c
+++ b/celt/bands.c
@@ -1450,7 +1450,7 @@ void quant_all_bands(int encode, const CELTMode *m, int start, int end,
    if (encode && resynth)
       lowband_scratch = _lowband_scratch;
    else
-      lowband_scratch = X_+M*eBands[m->nbEBands-1];
+      lowband_scratch = X_+M*eBands[m->effEBands-1];
    ALLOC(X_save, resynth_alloc, celt_norm);
    ALLOC(Y_save, resynth_alloc, celt_norm);
    ALLOC(X_save2, resynth_alloc, celt_norm);
-- 
GitLab