-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Webserver double freeing _currentHeaders on destruction #4350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That would make a good pull-request. |
@mongozmaki Would you like to submit a PR for this? It will also fix the same problem on the SecureServer, which uses this class' destructor. |
In issue esp8266#4350, @mongozmaki found that the web server was accessing a deleted variable in the destructor. Implement his suggested change and move the close() before any freeing. Could also have simply NULL'd out the _currentHeaders member after freeing as well. Fixes issue esp8266#4350
Yes, I tried creating a PR but didn't work for some reason. If I find a minor issue again, I will do that. |
In issue #4350, @mongozmaki found that the web server was accessing a deleted variable in the destructor. Implement his suggested change and move the close() before any freeing. Could also have simply NULL'd out the _currentHeaders member after freeing as well. Fixes issue #4350
No problem, @mongozmaki . I've referenced you in the change note, and appreciate the detailed error, repro instructions, and fix you did. Nothing for me to do, really. :) Next one, when you push to your private forked repo, you can go to its github website and there should be a "submit pull request" button right at the top of the page (for about 5 mins after a push) which should get you going. |
Destructor of ESP8266WebServer double-frees _currentHeaders.
The problem is, that the destructor frees
_currentHeaders
and sets_headerKeysCount=0
and than callsclose()
, which checksif(!_headerKeysCount)
(=true) and callscollectHeaders(0, 0)
which frees_currentHeaders
again (because it is not set tonullptr
).A fix would be to call
close()
in the beginning of the destructor.A more extensive fix would be to call collectHeaders(0, 0) in
begin()
and not inclose()
.Code fixed:
Sketch
Debug Messages
The text was updated successfully, but these errors were encountered: