Skip to content
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 boundary condition on resize #4016

Merged
merged 2 commits into from
Dec 26, 2017
Merged

Fix boundary condition on resize #4016

merged 2 commits into from
Dec 26, 2017

Conversation

boblemaire
Copy link
Contributor

@boblemaire boblemaire commented Dec 22, 2017

cbuf.size() must be at least one byte larger than cbuf.available() for
logic to work. reject request to resize = available. Issue #4002.

cbuf.size() must be at least one byte larger than cbuf.available() for
logic to work.  reject request to resize = available.
@devyte devyte merged commit e4043e9 into esp8266:master Dec 26, 2017
@devyte
Copy link
Collaborator

devyte commented Dec 26, 2017

Thanks for finding this. It took me a while to understand the underlying issue. For the record, you are also correct in that cbuf allocates 1byte more than it really uses. Therefore, you can't allow downsizing to the exact number of elements contained, and must allow to the number of elements + 1 and above.
It may be worth considering replacing this code with a wrapper around an STL-style container, or e.g.: boost's ring buffer, but for now, your fix is enough.

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