Commit 4099583465 for asterisk.org

commit 409958346573073dcf15349b626c3e02ac58c3bb
Author: Sven Andersen <66825717+gongsearch@users.noreply.github.com>
Date:   Tue Dec 1 21:03:22 2026 +0100

    codec_g722: Fix the output offset in g722tolin_framein().

    g722tolin_framein() indexed the int16_t output buffer with
    pvt->samples * sizeof(int16_t), i.e. at twice the number of samples
    already in the buffer. If a second frame is passed to framein before
    frameout empties the buffer, the decoded audio is written at the wrong
    position, leaving a gap of stale samples, and can be written past the
    end of the buffer, since the "Out of buffer space" check in
    framein() assumes the correct offset. ast_translate() currently calls
    frameout() after every frame, so the bug is latent there.

    The encoder side (lintog722_framein) already uses the byte offset
    pvt->datalen on outbuf.ui8 correctly.

    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

diff --git a/codecs/codec_g722.c b/codecs/codec_g722.c
index 6046dd382f..7172870299 100644
--- a/codecs/codec_g722.c
+++ b/codecs/codec_g722.c
@@ -109,7 +109,7 @@ static int g722tolin_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
 	/* g722_decode expects the samples to be in the invalid samples / 2 format */
 	in_samples = f->samples / 2;

-	out_samples = g722_decode(&tmp->g722, &pvt->outbuf.i16[pvt->samples * sizeof(int16_t)],
+	out_samples = g722_decode(&tmp->g722, &pvt->outbuf.i16[pvt->samples],
 		(uint8_t *) f->data.ptr, in_samples);

 	pvt->samples += out_samples;