From 1f4a029d107b017a43918d87f2ca8d531a1ebc23 Mon Sep 17 00:00:00 2001 From: Simon Goldschmidt Date: Thu, 4 Mar 2021 20:18:04 +0100 Subject: [PATCH] mqtt: check data_cb != NULL --- src/apps/mqtt/mqtt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/apps/mqtt/mqtt.c b/src/apps/mqtt/mqtt.c index 8e5c206a..0da1a405 100644 --- a/src/apps/mqtt/mqtt.c +++ b/src/apps/mqtt/mqtt.c @@ -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")); 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 */ if (remaining_length == 0 && qos > 0) { /* Send PUBACK for QoS 1 or PUBREC for QoS 2 */