Merge pull request #1101 from droloff/fix-npe

check payload to avoid npe
This commit is contained in:
Aircoookie 2020-08-20 08:44:09 +02:00 committed by GitHub
commit a8c530a3a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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