Add a check when publishing data to verify that if some data length is set, data pointer cannot be NULL, in which case an error is returned.

Signed-off-by: Marius Vikhammer <marius.vikhammer@espressif.com>
This commit is contained in:
Laurent Louf
2019-05-03 12:05:29 +02:00
committed by Marius Vikhammer
parent 04253b2b07
commit 2b04d177c7

View File

@ -430,6 +430,10 @@ mqtt_message_t *mqtt_msg_publish(mqtt_connection_t *connection, const char *topi
return fail_message(connection);
}
if (data == NULL && data_length > 0) {
return fail_message(connection);
}
if (qos > 0) {
if ((*message_id = append_message_id(connection, 0)) == 0) {
return fail_message(connection);