diff --git a/mongoose.c b/mongoose.c index f025262ef06e5648d053dd9cfed988001807c47e..a3a620128408947de4ba58f0209739f179bc365e 100644 --- a/mongoose.c +++ b/mongoose.c @@ -9691,11 +9691,11 @@ void mg_send_mqtt_handshake_opt(struct mg_connection *nc, const char *client_id, opts.flags |= MG_MQTT_HAS_PASSWORD; rem_len += (uint8_t) strlen(opts.password) + 2; } - if (opts.will_topic != NULL && opts.will_message != NULL) { - opts.flags |= MG_MQTT_HAS_WILL; - rem_len += (uint8_t) strlen(opts.will_topic) + 2; - rem_len += (uint8_t) strlen(opts.will_message) + 2; - } + if (opts.will_topic != NULL && opts.will_message != NULL) { + opts.flags |= MG_MQTT_HAS_WILL; + rem_len += (uint8_t) strlen(opts.will_topic) + 2; + rem_len += (uint8_t) strlen(opts.will_message) + 2; + } mg_send(nc, &header, 1); mg_send(nc, &rem_len, 1);