From: Jaroslav Kysela Date: Mon, 17 Oct 2022 11:52:51 +0000 (+0200) Subject: pcm: rate: fix the crash for the partial period copy X-Git-Tag: v1.2.8~4 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=9253f08fb784ad6a8b67b63e64732cb2f5694b6a;p=alsa-lib.git pcm: rate: fix the crash for the partial period copy The size argument in snd_pcm_rate_commit_area can be smaller than cont in drain. Return the original code. It should not make things worse. Perhaps, we can fill the rest of the period with silence in this case. Fixes: https://github.com/alsa-project/alsa-lib/issues/274 Signed-off-by: Jaroslav Kysela --- diff --git a/src/pcm/pcm_rate.c b/src/pcm/pcm_rate.c index e8815e8b..e5d8eddd 100644 --- a/src/pcm/pcm_rate.c +++ b/src/pcm/pcm_rate.c @@ -770,7 +770,7 @@ static snd_pcm_sframes_t snd_pcm_rate_forward(snd_pcm_t *pcm ATTRIBUTE_UNUSED, static int snd_pcm_rate_commit_area(snd_pcm_t *pcm, snd_pcm_rate_t *rate, snd_pcm_uframes_t appl_offset, - snd_pcm_uframes_t size, + snd_pcm_uframes_t size ATTRIBUTE_UNUSED, snd_pcm_uframes_t slave_size) { snd_pcm_uframes_t cont = pcm->buffer_size - appl_offset; @@ -816,7 +816,7 @@ static int snd_pcm_rate_commit_area(snd_pcm_t *pcm, snd_pcm_rate_t *rate, pcm->format); snd_pcm_areas_copy(rate->pareas, cont, areas, 0, - pcm->channels, size - cont, + pcm->channels, pcm->period_size - cont, pcm->format); snd_pcm_rate_write_areas1(pcm, rate->pareas, 0, rate->sareas, 0);