Add additional chk

This commit is contained in:
Theo Arends 2020-12-23 14:30:09 +01:00
parent 5a29fffcc6
commit 46a66c8194
1 changed files with 3 additions and 3 deletions

View File

@ -535,10 +535,10 @@ void Z_Device::jsonPublishAttrList(const char * json_prefix, const Z_attribute_l
if (Settings.flag4.zigbee_distinct_topics) { if (Settings.flag4.zigbee_distinct_topics) {
char subtopic[TOPSZ]; char subtopic[TOPSZ];
if (Settings.flag4.zb_topic_fname && friendlyName) { if (Settings.flag4.zb_topic_fname && friendlyName && strlen(friendlyName)) {
// Clean special characters and check size of friendly name // Clean special characters
char stemp[TOPSZ]; char stemp[TOPSZ];
strlcpy(stemp, (!strlen(friendlyName)) ? MQTT_TOPIC : friendlyName, sizeof(stemp)); strlcpy(stemp, friendlyName, sizeof(stemp));
MakeValidMqtt(0, stemp); MakeValidMqtt(0, stemp);
snprintf_P(subtopic, sizeof(subtopic), PSTR("%s/%s"), TasmotaGlobal.mqtt_topic, stemp); snprintf_P(subtopic, sizeof(subtopic), PSTR("%s/%s"), TasmotaGlobal.mqtt_topic, stemp);
} else { } else {