mqtt: check data_cb != NULL

This commit is contained in:
Simon Goldschmidt 2021-03-04 20:18:04 +01:00
parent d7a0757764
commit 1f4a029d10

View File

@ -770,7 +770,9 @@ mqtt_message_received(mqtt_client_t *client, u8_t fixed_hdr_len, u16_t length, u
LWIP_DEBUGF(MQTT_DEBUG_WARN,( "mqtt_message_received: Received short packet (payload)\n")); LWIP_DEBUGF(MQTT_DEBUG_WARN,( "mqtt_message_received: Received short packet (payload)\n"));
goto out_disconnect; goto out_disconnect;
} }
client->data_cb(client->inpub_arg, var_hdr_payload + payload_offset, payload_length, remaining_length == 0 ? MQTT_DATA_FLAG_LAST : 0); if (client->data_cb != NULL) {
client->data_cb(client->inpub_arg, var_hdr_payload + payload_offset, payload_length, remaining_length == 0 ? MQTT_DATA_FLAG_LAST : 0);
}
/* Reply if QoS > 0 */ /* Reply if QoS > 0 */
if (remaining_length == 0 && qos > 0) { if (remaining_length == 0 && qos > 0) {
/* Send PUBACK for QoS 1 or PUBREC for QoS 2 */ /* Send PUBACK for QoS 1 or PUBREC for QoS 2 */