From 035437c8dc01bdf657e1c25fef1dcbef370f4599 Mon Sep 17 00:00:00 2001 From: MartinKlang Date: Wed, 29 Mar 2023 18:31:14 +0200 Subject: [PATCH] Reset client->send_offset on reinit If the connection is re-established while sending multi-part messages then MQTT-C will send garbage data from an old offset into the re-initialised message queue --- src/mqtt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mqtt.c b/src/mqtt.c index d914c1a..c7f50b6 100644 --- a/src/mqtt.c +++ b/src/mqtt.c @@ -189,6 +189,7 @@ void mqtt_reinit(struct mqtt_client* client, client->socketfd = socketfd; mqtt_mq_init(&client->mq, sendbuf, sendbufsz); + client->send_offset = 0; client->recv_buffer.mem_start = recvbuf; client->recv_buffer.mem_size = recvbufsz;