bytebuffer apend crashfix #26
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I found, I believe, a very scary bug.
https://github.com/elysium-project/server/blob/development/src/shared/ByteBuffer.h#L402
On a call to SendMeleeAttackStop() from map update, I am assuming because I was targetting a temprary creature spawn that despawned as as it happened (i have reproduced this multiple times btw), buffer.wpos() returned 8, while buffer.size() is 0. Thus, when buffer.contents() try to run return &_storage[0]; a crash happens.(edited)
I attempted to replace buffer.wpos() with buffer.size(), and I am no longer able to reproduce the bug, but this is really old code from what I can find, so it strikes me as odd that i's always been buffer.wpos(), and noone has noticed or done anything about it
is anyone more familiar with the ByteBuffer class able to see if .size() is a valid replacement for .wpos()? It seems much safer to me. I assume the idea is that wpos should always be safe to use, but wpos can be changed a ton of places so its hard to imagine it can't fail (as it did for me now)