From da8b189b43738ca7b1f33286a4004260222bce72 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sat, 13 Aug 2022 01:52:44 +0200 Subject: [PATCH] protect from NULL deref if running without prog track --- DCCWaveform.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/DCCWaveform.h b/DCCWaveform.h index 108a63d..1dad1b2 100644 --- a/DCCWaveform.h +++ b/DCCWaveform.h @@ -59,10 +59,12 @@ class DCCWaveform { #else // extrafudge is added when we know that the resets will first come extrafudge packets in the future inline void clearResets(byte extrafudge=0) { + if ((isMainTrack ? rmtMainChannel : rmtProgChannel) == NULL) return; resetPacketBase = isMainTrack ? rmtMainChannel->packetCount() : rmtProgChannel->packetCount(); resetPacketBase += extrafudge; }; inline byte getResets() { + if ((isMainTrack ? rmtMainChannel : rmtProgChannel) == NULL) return 0; uint32_t packetcount = isMainTrack ? rmtMainChannel->packetCount() : rmtProgChannel->packetCount(); uint32_t count = packetcount - resetPacketBase; // Beware of unsigned interger arithmetic.