From 8e8d85ef61ed37b3eea55d9fae3f73ecdb96be7b Mon Sep 17 00:00:00 2001 From: Dave Behnke <916775+dbehnke@users.noreply.github.com> Date: Sun, 28 Dec 2025 04:33:07 -0500 Subject: [PATCH] Fix M17 crash: capture CodecType before Header invalidation in Input --- reflector/M17Protocol.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/reflector/M17Protocol.cpp b/reflector/M17Protocol.cpp index f544006..e72157e 100644 --- a/reflector/M17Protocol.cpp +++ b/reflector/M17Protocol.cpp @@ -76,13 +76,15 @@ void CM17Protocol::Task(void) // callsign muted? if ( g_GateKeeper.MayTransmit(Header->GetMyCallsign(), Ip, EProtocol::m17, Header->GetRpt2Module()) ) { + // Inspect Header to know codec type (3200 vs 1600) + ECodecType cType = Header->GetCodecIn(); + OnDvHeaderPacketIn(Header, Ip); // xrf needs a voice frame every 20 ms and an M17 frame is 40 ms, so we need to split it // M17 3200 payload is 16 bytes. We need two 8-byte frames. - // Inspect Header to know codec type (3200 vs 1600) - ECodecType cType = Header->GetCodecIn(); + // Header is now invalid (moved in OnDvHeaderPacketIn), so we use cType // Only split if we have enough data (standard M17 is 16 bytes for 3200, 8 for 1600) // CDvFramePacket constructor from M17 copies 16 bytes to m_TCPack.m17