mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-13 23:01:20 +10:00
Bug fix for problem discovered when setting length to 1 for additional parameters
The initialization of the buffer holding the value stopped before the last character and storage did not take into account the extra-byte for end of string.
This commit is contained in:
+2
-2
@@ -34,7 +34,7 @@ void WiFiManagerParameter::init(const char *id, const char *placeholder, const c
|
||||
_placeholder = placeholder;
|
||||
_length = length;
|
||||
_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) {
|
||||
@@ -597,7 +597,7 @@ void WiFiManager::handleWifiSave() {
|
||||
//read parameter
|
||||
String value = server->arg(_params[i]->getID()).c_str();
|
||||
//store it in array
|
||||
value.toCharArray(_params[i]->_value, _params[i]->_length);
|
||||
value.toCharArray(_params[i]->_value, _params[i]->_length + 1);
|
||||
DEBUG_WM(F("Parameter"));
|
||||
DEBUG_WM(_params[i]->getID());
|
||||
DEBUG_WM(value);
|
||||
|
||||
Reference in New Issue
Block a user