Only call pb_release when validDecode.

This commit is contained in:
Eric Severance 2024-12-16 20:44:27 -08:00
parent de628f5649
commit d9b900b287
No known key found for this signature in database
GPG Key ID: 340D1DA2A5A64A62

View File

@ -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;
};