diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 79a25ab..1512cad 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -42,11 +42,11 @@ void WiFiManagerParameter::init(const char *id, const char *placeholder, const c _length = length; _labelPlacement = labelPlacement; _value = new char[length + 1]; - for (int i = 0; i < length; i++) { + for (int i = 0; i < length + 1; i++) { _value[i] = 0; } if (defaultValue != NULL) { - strncpy(_value, defaultValue, length+1); // length+1 due to null terminated string + strncpy(_value, defaultValue, length + 1); // length+1 due to null terminated string } _customHTML = custom;