Commit 46dd03daba for ffmpeg
commit 46dd03dabacea4b35ef1b3853c80920ec67efb43
Author: lusoris <lusoris@proton.me>
Date: Sat Oct 31 03:54:19 2026 +0100
avcodec/aacenc: make psychoacoustic window-count bound explicit
GCC 16.2.1 reports -Wstringop-overflow in frame encoding because the
psychoacoustic window count, which comes from an indirect model
callback, is not visibly bounded before it indexes the per-window
arrays. The installed window callbacks and the LFE path already return
one or eight windows. Check that explicitly so the bound is visible to
the compiler, returning AVERROR_BUG if it is ever not met. Input
acceptance and encoding with either window count are unchanged.
Signed-off-by: lusoris <lusoris@proton.me>
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index aadb9e6e17..96612625b2 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -1358,6 +1358,12 @@ static int aac_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
wi[ch] = s->psy.model->window(&s->psy, samples2, la, s->cur_channel,
ics->window_sequence[0]);
}
+ if (wi[ch].num_windows != 1 && wi[ch].num_windows != 8) {
+ av_log(avctx, AV_LOG_ERROR,
+ "Psychoacoustic model returned invalid window count %d\n",
+ wi[ch].num_windows);
+ return AVERROR_BUG;
+ }
ics->window_sequence[1] = ics->window_sequence[0];
ics->window_sequence[0] = wi[ch].window_type[0];
ics->use_kb_window[1] = ics->use_kb_window[0];