-
Notifications
You must be signed in to change notification settings - Fork 61
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 an off-by-one error that causes memory corruption. #69
Conversation
We read up to bsize bytes from gInFile, so allocate as much memory.
It's more "off by 1-3" than "off by one", but it looks correct :) |
@pkern Do you have a test we can add? Idealy, the test would fail before the PR but succeed with the PR. |
Unfortunately I don't have one. Compiled with tcmalloc it was very unhappy and it instantly crashed under ASan. |
Yeah, this would be a pretty difficult thing to test for, except under valgrind/ASan. |
Confirmed. I just cherry-picked your commit on top of #41 and did a before after valgrind check. Before:
After:
I am merging. @pkern Thank you for the contribution. |
We read up to bsize bytes from gInFile, so allocate as much memory.