Skip to content

Commit

Permalink
fix MQTT crash (#3127)
Browse files Browse the repository at this point in the history
  • Loading branch information
mverch67 authored Jan 24, 2024
1 parent 4ae5443 commit f2c04c5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/mqtt/MQTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length)
}
delete json_value;
} else {
if (!pb_decode_from_bytes(payload, length, &meshtastic_ServiceEnvelope_msg, &e)) {
if (length == 0) {
LOG_WARN("Empty MQTT payload received, topic %s!\n", topic);
return;
} else if (!pb_decode_from_bytes(payload, length, &meshtastic_ServiceEnvelope_msg, &e)) {
LOG_ERROR("Invalid MQTT service envelope, topic %s, len %u!\n", topic, length);
return;
} else {
Expand Down

0 comments on commit f2c04c5

Please sign in to comment.