From 855949936368940f71577af4ca89f95e15f39f5b Mon Sep 17 00:00:00 2001 From: Tobias Schlager Date: Tue, 17 May 2022 11:14:01 +0200 Subject: [PATCH] G722: Fix buffer overflow (#20) --- src/audiofilters/msg722.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audiofilters/msg722.c b/src/audiofilters/msg722.c index adc88c1463..cca5454de0 100644 --- a/src/audiofilters/msg722.c +++ b/src/audiofilters/msg722.c @@ -267,7 +267,7 @@ static void dec_process(MSFilter *f) { /* introduce delay (TRANSITION_DELAY ms) */ generic_plc_update_continuity_buffer(s->plc_context, om->b_wptr, declen*sizeof(int16_t)); - if (s->plc_context->plc_samples_used!=0) { + if (s->plc_context->plc_samples_used!=0 && declen >= 2*16*TRANSITION_DELAY) { /* we were doing PLC, now resuming with normal audio, continuity buffer is twice the transition delay lengths, * the second half is untouched by the update function and contains transition data generated by PLC */ generic_plc_transition_mix(((int16_t *)(om->b_wptr))+16*TRANSITION_DELAY, ((int16_t *)(s->plc_context->continuity_buffer))+16*TRANSITION_DELAY, 16*TRANSITION_DELAY);