From 407d175f5db77f54908483929372c5ee3c47634c Mon Sep 17 00:00:00 2001 From: Bartosz Podrygajlo Date: Fri, 28 Nov 2025 09:00:28 +0100 Subject: [PATCH] Clear memory in shm_td_iq_channel after RX Clear memory in shm_td_iq_channel after RX. This prevents the IQ from being read twice. This can happen if the application crashes and will keep the other side reading historical IQ samples. --- common/utils/shm_iq_channel/shm_td_iq_channel.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/utils/shm_iq_channel/shm_td_iq_channel.c b/common/utils/shm_iq_channel/shm_td_iq_channel.c index ecebbaf494..169eb9f3f2 100644 --- a/common/utils/shm_iq_channel/shm_td_iq_channel.c +++ b/common/utils/shm_iq_channel/shm_td_iq_channel.c @@ -208,8 +208,11 @@ IQChannelErrorType shm_td_iq_channel_rx(ShmTDIQChannel *channel, size_t num_samples_first_copy = CIRCULAR_BUFFER_SIZE - first_sample; memcpy(tx_iq_data, base_ptr + first_sample, num_samples_first_copy * sizeof(sample_t)); memcpy(tx_iq_data + num_samples_first_copy, base_ptr, (num_samples - num_samples_first_copy) * sizeof(sample_t)); + memset(base_ptr + first_sample, 0, num_samples_first_copy * sizeof(sample_t)); + memset(base_ptr, 0, (num_samples - num_samples_first_copy) * sizeof(sample_t)); } else { memcpy(tx_iq_data, base_ptr + first_sample, num_samples * sizeof(sample_t)); + memset(base_ptr + first_sample, 0, num_samples * sizeof(sample_t)); } return CHANNEL_NO_ERROR; }