From d9b900b287fd9e6d69e79da5de3c14b86d323d0e Mon Sep 17 00:00:00 2001 From: Eric Severance Date: Mon, 16 Dec 2024 20:44:27 -0800 Subject: [PATCH] Only call pb_release when validDecode. --- src/mqtt/MQTT.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index d55f6af11..246630615 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -48,7 +48,11 @@ struct DecodedServiceEnvelope : public meshtastic_ServiceEnvelope { validDecode(pb_decode_from_bytes(payload, length, &meshtastic_ServiceEnvelope_msg, this)) { } - ~DecodedServiceEnvelope() { pb_release(&meshtastic_ServiceEnvelope_msg, this); } + ~DecodedServiceEnvelope() + { + if (validDecode) + pb_release(&meshtastic_ServiceEnvelope_msg, this); + } // Clients must check that this is true before using. const bool validDecode; };