From bb29deb45a37c9435daffa0780c8b85dadca33c4 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Sat, 2 Dec 2023 13:13:55 +0200 Subject: [PATCH] acp: avoid copying structure into itself sync_mixer() calls d->set_volume(d, &d->real_volume); which makes v and &dev->real_volume point to the same memory area and valgrind complains: Source and destination overlap in memcpy(0xcc53e2c, 0xcc53e2c, 260) at 0x488CFA0: __GI_memcpy (vg_replace_strmem.c:1121) by 0xBB0803F: set_volume (acp.c:1143) by 0xBB0EDCB: acp_device_set_port (acp.c:1897) by 0xBA9CD87: impl_set_param (alsa-acp-device.c:757) because the compiler apparently implicitly converts this into a memcpy() and memcpy(3) explicitly says "The memory areas must not overlap." --- spa/plugins/alsa/acp/acp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spa/plugins/alsa/acp/acp.c b/spa/plugins/alsa/acp/acp.c index 98f6326d1..ef2a287cf 100644 --- a/spa/plugins/alsa/acp/acp.c +++ b/spa/plugins/alsa/acp/acp.c @@ -1140,7 +1140,8 @@ static void set_volume(pa_alsa_device *dev, const pa_cvolume *v) { pa_cvolume r; - dev->real_volume = *v; + if (v != &dev->real_volume) + dev->real_volume = *v; if (!dev->mixer_handle) return;