From 80e40a1467458799adf25743b380d0eef798c429 Mon Sep 17 00:00:00 2001 From: jirif Date: Thu, 7 Jun 2018 15:09:32 +0200 Subject: [PATCH] Fixed null pointer reference --- src/main/rx/fport.c | 2 +- src/main/telemetry/smartport.c | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/rx/fport.c b/src/main/rx/fport.c index 227c15514..f31624ee6 100644 --- a/src/main/rx/fport.c +++ b/src/main/rx/fport.c @@ -347,7 +347,7 @@ static bool fportProcessFrame(const rxRuntimeConfig_t *rxRuntimeConfig) if (clearToSend) { DEBUG_SET(DEBUG_FPORT, DEBUG_FPORT_TELEMETRY_DELAY, currentTimeUs - lastTelemetryFrameReceivedUs); - if (consecutiveSensorCount >= FPORT_TELEMETRY_MAX_CONSECUTIVE_SENSORS && !smartPortPayloadContainsMSP(mspPayload)) { + if (consecutiveSensorCount >= FPORT_TELEMETRY_MAX_CONSECUTIVE_SENSORS && !(mspPayload && smartPortPayloadContainsMSP(mspPayload))) { // Stop one cycle to avoid saturating the buffer in the RX, since the // downstream bandwidth doesn't allow sensor sensors on every cycle. // We allow MSP frames to run over the resting period, expecting that diff --git a/src/main/telemetry/smartport.c b/src/main/telemetry/smartport.c index 3670cc367..59c3a5a29 100644 --- a/src/main/telemetry/smartport.c +++ b/src/main/telemetry/smartport.c @@ -464,18 +464,15 @@ void processSmartPortTelemetry(smartPortPayload_t *payload, volatile bool *clear static uint8_t smartPortIdOffset = 0; #endif - if (payload) { - // do not check the physical ID here again - // unless we start receiving other sensors' packets - #if defined(USE_MSP_OVER_TELEMETRY) - if (smartPortPayloadContainsMSP(payload)) { - // Pass only the payload: skip frameId - uint8_t *frameStart = (uint8_t *)&payload->valueId; - smartPortMspReplyPending = handleMspFrame(frameStart, SMARTPORT_MSP_PAYLOAD_SIZE); - } -#endif + if (payload && smartPortPayloadContainsMSP(payload)) { + // Do not check the physical ID here again + // unless we start receiving other sensors' packets + // Pass only the payload: skip frameId + uint8_t *frameStart = (uint8_t *)&payload->valueId; + smartPortMspReplyPending = handleMspFrame(frameStart, SMARTPORT_MSP_PAYLOAD_SIZE); } +#endif bool doRun = true; while (doRun && *clearToSend) {