check payload to avoid npe

This commit is contained in:
Dirk Roloff 2020-08-20 00:13:06 +02:00
parent 39a80f8dc7
commit 3b4bccd0a7

View File

@ -56,6 +56,12 @@ void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties
DEBUG_PRINT("MQTT msg: ");
DEBUG_PRINTLN(topic);
// paranoia check to avoid npe if no payload
if (payload==nullptr) {
DEBUG_PRINTLN("no payload -> leave");
return;
}
DEBUG_PRINTLN(payload);
//no need to check the topic because we only get topics we are subscribed to