From 3611293a9895f4b10e56109ff05a701d225a6fa5 Mon Sep 17 00:00:00 2001 From: Richard Nauber Date: Fri, 28 Jan 2022 21:02:02 +0100 Subject: [PATCH] Prevent null pointer dereference in setup() if radio is not available. --- src/main.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7ad375db5..db908a5eb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -658,16 +658,16 @@ void setup() if (!rIf) RECORD_CRITICALERROR(CriticalErrorCode_NoRadio); - else + else{ router->addInterface(rIf); - // Calculate and save the bit rate to myNodeInfo - // TODO: This needs to be added what ever method changes the channel from the phone. - myNodeInfo.bitrate = (float(Constants_DATA_PAYLOAD_LEN) / - (float(rIf->getPacketTime(Constants_DATA_PAYLOAD_LEN))) - ) * 1000; - DEBUG_MSG("myNodeInfo.bitrate = %f bytes / sec\n", myNodeInfo.bitrate); - + // Calculate and save the bit rate to myNodeInfo + // TODO: This needs to be added what ever method changes the channel from the phone. + myNodeInfo.bitrate = (float(Constants_DATA_PAYLOAD_LEN) / + (float(rIf->getPacketTime(Constants_DATA_PAYLOAD_LEN))) + ) * 1000; + DEBUG_MSG("myNodeInfo.bitrate = %f bytes / sec\n", myNodeInfo.bitrate); + } // This must be _after_ service.init because we need our preferences loaded from flash to have proper timeout values PowerFSM_setup(); // we will transition to ON in a couple of seconds, FIXME, only do this for cold boots, not waking from SDS