Skip to content

Update WString.cpp - fixes #3516 #3533

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

Merged
merged 5 commits into from
Sep 11, 2017
Merged

Update WString.cpp - fixes #3516 #3533

merged 5 commits into from
Sep 11, 2017

Conversation

adams13x13
Copy link
Contributor

@adams13x13 adams13x13 commented Aug 20, 2017

If a string should be expanded (e.g. string concatenation, function "changeBuffer()") and there is no enough memory for a new size (realloc() fails), the old memory is not deallocated, but the pointer is ovewritten with zero. This is a memory leak. With this change, the string will retain its old value and will be safely disposed; changeBuffer() returns an error.


realloc() is called with newSize > 0 (at least 16), so newbuffer==0 means the old memory was not deallocated. Therefore, the pointer should still point to the old buffer. This change should resolve issue #3516.

realloc() is called with newSize > 0 (at least 16), so newbuffer==0 means the old memory was not deallocated. Therefore, the pointer should still point to the old buffer. This change should resolve issue esp8266#3516.
@igrr igrr merged commit 613f04c into esp8266:master Sep 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants