1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3600
https://gitlab.freedesktop.org/pipewire/pipewire/-/commit/920beea3eb55ee7156bd8c00a201bdcafa0df5b0
From 920beea3eb55ee7156bd8c00a201bdcafa0df5b0 Mon Sep 17 00:00:00 2001
From: Wim Taymans <wtaymans@redhat.com>
Date: Sun, 22 Oct 2023 17:26:25 +0200
Subject: [PATCH] alsa: guard agaist NULL areas
snd_pcm_ioplug_mmap_areas() can fail and return NULL
Fixes #3600
--- a/pipewire-alsa/alsa-plugins/pcm_pipewire.c
+++ b/pipewire-alsa/alsa-plugins/pcm_pipewire.c
@@ -309,21 +309,21 @@ snd_pcm_pipewire_process(snd_pcm_pipewire_t *pw, struct pw_buffer *b,
xfer = nframes;
if (xfer > 0) {
const snd_pcm_channel_area_t *areas = snd_pcm_ioplug_mmap_areas(io);
- const snd_pcm_uframes_t offset = hw_ptr % io->buffer_size;
-
- if (io->stream == SND_PCM_STREAM_PLAYBACK)
- snd_pcm_areas_copy_wrap(pwareas, 0, nframes,
- areas, offset,
- io->buffer_size,
- io->channels, xfer,
- io->format);
- else
- snd_pcm_areas_copy_wrap(areas, offset,
- io->buffer_size,
- pwareas, 0, nframes,
- io->channels, xfer,
- io->format);
-
+ if (areas != NULL) {
+ const snd_pcm_uframes_t offset = hw_ptr % io->buffer_size;
+ if (io->stream == SND_PCM_STREAM_PLAYBACK)
+ snd_pcm_areas_copy_wrap(pwareas, 0, nframes,
+ areas, offset,
+ io->buffer_size,
+ io->channels, xfer,
+ io->format);
+ else
+ snd_pcm_areas_copy_wrap(areas, offset,
+ io->buffer_size,
+ pwareas, 0, nframes,
+ io->channels, xfer,
+ io->format);
+ }
hw_ptr += xfer;
if (hw_ptr >= pw->boundary)
hw_ptr -= pw->boundary;
--
GitLab
|