1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-23 12:51:24 +01:00

protect from NULL pointer deref in ESP32 code when no MAIN rmt cannel is present

This commit is contained in:
Harald Barth 2022-08-13 17:36:53 +02:00
parent 059fd1b193
commit 905b2c0148

View File

@ -250,19 +250,27 @@ void DCCWaveform::schedulePacket(const byte buffer[], byte byteCount, byte repea
{
int ret;
do {
if(isMainTrack)
ret = rmtMainChannel->RMTfillData(pendingPacket, pendingLength, pendingRepeats);
else
ret = rmtProgChannel->RMTfillData(pendingPacket, pendingLength, pendingRepeats);
if(isMainTrack) {
if (rmtMainChannel != NULL)
ret = rmtMainChannel->RMTfillData(pendingPacket, pendingLength, pendingRepeats);
} else {
if (rmtProgChannel != NULL)
ret = rmtProgChannel->RMTfillData(pendingPacket, pendingLength, pendingRepeats);
}
} while(ret > 0);
}
}
bool DCCWaveform::getPacketPending() {
if(isMainTrack)
if(isMainTrack) {
if (rmtMainChannel == NULL)
return true;
return rmtMainChannel->busy();
else
} else {
if (rmtProgChannel == NULL)
return true;
return rmtProgChannel->busy();
}
}
void IRAM_ATTR DCCWaveform::loop() {
DCCACK::checkAck(progTrack.getResets());