mqtt logging: allocate _path according to string length

This commit is contained in:
technyon
2023-02-07 19:27:42 +01:00
parent 7848dde274
commit ad648cc22d

View File

@@ -57,11 +57,10 @@ void W5500Device::initialize()
if(_preferences->getBool(preference_mqtt_log_enabled))
{
_path = new char[200];
memset(_path, 0, sizeof(_path));
String pathStr = _preferences->getString(preference_mqtt_lock_path);
pathStr.concat(mqtt_topic_log);
_path = new char[pathStr.length() + 1];
memset(_path, 0, sizeof(_path));
strcpy(_path, pathStr.c_str());
Log = new MqttLogger(this, _path, MqttLoggerMode::MqttAndSerial);
}