1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 23:56:13 +01:00

protect from NULL deref if running without prog track

This commit is contained in:
Harald Barth 2022-08-13 01:52:44 +02:00
parent a985356f0c
commit da8b189b43

View File

@ -59,10 +59,12 @@ class DCCWaveform {
#else #else
// extrafudge is added when we know that the resets will first come extrafudge packets in the future // extrafudge is added when we know that the resets will first come extrafudge packets in the future
inline void clearResets(byte extrafudge=0) { inline void clearResets(byte extrafudge=0) {
if ((isMainTrack ? rmtMainChannel : rmtProgChannel) == NULL) return;
resetPacketBase = isMainTrack ? rmtMainChannel->packetCount() : rmtProgChannel->packetCount(); resetPacketBase = isMainTrack ? rmtMainChannel->packetCount() : rmtProgChannel->packetCount();
resetPacketBase += extrafudge; resetPacketBase += extrafudge;
}; };
inline byte getResets() { inline byte getResets() {
if ((isMainTrack ? rmtMainChannel : rmtProgChannel) == NULL) return 0;
uint32_t packetcount = isMainTrack ? uint32_t packetcount = isMainTrack ?
rmtMainChannel->packetCount() : rmtProgChannel->packetCount(); rmtMainChannel->packetCount() : rmtProgChannel->packetCount();
uint32_t count = packetcount - resetPacketBase; // Beware of unsigned interger arithmetic. uint32_t count = packetcount - resetPacketBase; // Beware of unsigned interger arithmetic.