Skip to content

Commit 02b10cf

Browse files
committed
proposed fix
1 parent 6d268e3 commit 02b10cf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/MqttClient.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,15 @@ void MqttClient::setTxPayloadSize(unsigned short size)
835835
{
836836
// NOOJ WAS HERE
837837
log_i("MqttClient::setTxPayloadSize(): NOOJ says: _txPayloadBuffer should be freed and NULLed here.");
838+
839+
// TODO: Be clever and try to preserve existing _txPayloadBuffer contents?
840+
// TODO: Check if this messes up the state of pending messages
841+
if (_txPayloadBuffer) {
842+
free(_txPayloadBuffer);
843+
_txPayloadBuffer = NULL;
844+
_txPayloadBufferIndex = 0;
845+
}
846+
838847
_tx_payload_buffer_size = size;
839848
}
840849

0 commit comments

Comments
 (0)