Skip to content

Commit

Permalink
Check for payload != NULL in smartPortPayloadContainsMSP()
Browse files Browse the repository at this point in the history
When calling it from the fport driver, the payload might be NULL in
some cases, causing an invalid dereference.

Found by @jirif on betaflight/betaflight#6060
  • Loading branch information
fiam committed Jun 7, 2018
1 parent f7f8c46 commit 86d4437
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/telemetry/smartport.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void smartPortSendByte(uint8_t c, uint16_t *checksum, serialPort_t *port)

bool smartPortPayloadContainsMSP(const smartPortPayload_t *payload)
{
return payload->frameId == FSSP_MSPC_FRAME_SMARTPORT || payload->frameId == FSSP_MSPC_FRAME_FPORT;
return payload && (payload->frameId == FSSP_MSPC_FRAME_SMARTPORT || payload->frameId == FSSP_MSPC_FRAME_FPORT);
}

void smartPortWriteFrameSerial(const smartPortPayload_t *payload, serialPort_t *port, uint16_t checksum)
Expand Down

0 comments on commit 86d4437

Please sign in to comment.