mqtt: check data_cb != NULL

This commit is contained in:
Simon Goldschmidt 2021-03-04 20:18:04 +01:00 committed by Erik Ekman
parent 3b745f7154
commit f67f2692d4

View File

@ -772,7 +772,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 */