-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
Fix memory leak and undefined behavour in Updater.cpp (UpdaterClass) #8671
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Codefix looks good to me. Is this targeting the correct branch?
@mrengineer7777 Not sure perhaps targeting |
no. leave it as is. We will not update 2.x anymore and will merge 5.1 into master to focus on 3.0.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MathewHDYT When updating this part of code, can you change the error messages as suggested? :) Thanks, otherwise LGTM.
Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com>
Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com>
Description of Change
The pull request aims to fix undefined behaviour and a memory leak of 16 bytes every time the
UpdaterClass
is used, this occurs because the_skipBuffer
is not freed correctly and the_buffer
is deleted but using the C++ styledelete[]
, even tough the C style memory allocationmalloc
was used. Which is not compatible and is undefined behavour. Meaning it might work on some devices on others it might crash and on some it might do other things.The changes are compatible with the current API and do not change anything about the
UpdaterClass
public or private method. It doesn't even change the private members. It only adjusts the memory allocation to always use C++ stylenew
and to actually free the created memory withdelete[]
.A more detailed description can be found in the issue mentioned below as well.
Tests scenarios
The changed code has been tested with an ESP32 and updating the device with the
UpdaterClass
over OTA.Related links
Closes #7984