mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 09:05:56 +03:00
[GH-ISSUE #1528] A bug in the init() method of the WiFiManagerParameter class #1304
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#1304
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Mollayo on GitHub (Dec 1, 2022).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1528
I believe I found a bug in the init() method of the WiFiManagerParameter class.
In this init() method, the value of _length is set to 1 by default. See here:
github.com/tzapu/WiFiManager@9f5981e2fd/WiFiManager.cpp (L61)The _value variable is also initialised to nullptr.
This init() method is then using the setValue() method to allocate the pointer for _value. However, the allocation is not made in case the length parameter in the init() function is set to 1 because of the condition "if(_length != length)" not being satisfied. See here:
github.com/tzapu/WiFiManager@9f5981e2fd/WiFiManager.cpp (L91)In consequence, the _value variable is still equal to nullptr after calling the init() method, making WifiManager to crash.
One solution would be to write " _value = new char[_length + 1]; " instead of "_value = nullptr;" at this line:
github.com/tzapu/WiFiManager@fe9774fe0f/WiFiManager.cpp (L62)@tablatronix commented on GitHub (Dec 1, 2022):
Yeah there are 2 issues on this, I have not had a chance to look at it
#1504
#1521
@tablatronix commented on GitHub (Dec 1, 2022):
or
if(_length != length || _value == nullptr){perhaps?@tablatronix commented on GitHub (Dec 1, 2022):
I forget why I used length =1
I think 0 made it not possible to detect un-initialized params or out of scope objs.
at some point this will have to be rewritten with smart pointers or safer memory handling