MQTT: Fix possible bug in connect message generation that WILL flag can be set without appending a will message

The boolean condition of setting the WILL flag differs from that of appending the will message
Found by Axel Lin
(I fixed it the same way as Axel suggested, but I wanted a different commit message)
(cherry picked from commit 6d5ddb7139)
This commit is contained in:
Dirk Ziegelmeier 2017-01-08 19:07:43 +01:00 committed by goldsimon
parent 4deaebae44
commit 890c5982a1

View File

@ -1292,7 +1292,7 @@ mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ip_addr, u16_t port,
/* Append client id */
mqtt_output_append_string(&client->output, client_info->client_id, client_id_length);
/* Append will message if used */
if (will_topic_len > 0) {
if ((flags & MQTT_CONNECT_FLAG_WILL) != 0) {
mqtt_output_append_string(&client->output, client_info->will_topic, will_topic_len);
mqtt_output_append_string(&client->output, client_info->will_msg, will_msg_len);
}