On OpenBSD 7.8 (which uses sndiod) the audio volume component of
slstatus reliably segfaults when the sndio server is switched at
runtime, for example with 'sndioctl server.device=1' when the current
device is server.device-0.
The following minimal patch adds a check to prevent a NULL pointer
dereference and avoid the segfault.
Tested locally on OpenBSD 7.8/amd64, resolves the issue.
From 0a3a51ff2663c70fe2e1cc5a1b13fd75ad2e48ba Mon Sep 17 00:00:00 2001
From: Chris Billington <[email protected]>
Date: Fri, 21 Nov 2025 12:31:40 +0800
Subject: [PATCH] volume: avoid NULL dereference in onval() on sndio
device switch
---
components/volume.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/components/volume.c b/components/volume.c
index 6cec556..23ddfc5 100644
--- a/components/volume.c
+++ b/components/volume.c
@@ -89,6 +89,8 @@
if (c->addr == addr)
break;
}
+ if(c == NULL)
+ return;
c->val = val;
}
--
2.51.0
Patch is also attached because pasting it inline here messes up the
formatting somewhat.
--
Chris Billington
>From 0a3a51ff2663c70fe2e1cc5a1b13fd75ad2e48ba Mon Sep 17 00:00:00 2001
From: Chris Billington <[email protected]>
Date: Fri, 21 Nov 2025 12:31:40 +0800
Subject: [PATCH] volume: avoid NULL dereference in onval() on sndio device
switch
---
components/volume.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/components/volume.c b/components/volume.c
index 6cec556..23ddfc5 100644
--- a/components/volume.c
+++ b/components/volume.c
@@ -89,6 +89,8 @@
if (c->addr == addr)
break;
}
+ if(c == NULL)
+ return;
c->val = val;
}
--
2.51.0