mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-09 04:19:10 -04:00
Avoid an (untriggerable so far) crash bug in bufferevent_free()
We were saying mm_free(bufev - bufev->be_ops->mem_offset); when we should have said mm_free(((char*)bufev) - bufev->be_ops->mem_offset); In other words, if mem_offset had ever been nonzero, then instead of backing up mem_offset bytes to find the thing we were supposed to free, we would have backed up mem_offset*sizeof(struct bufferevent) bytes, and freed something completely crazy. Spotted thanks to a conversation with Jardel Weyrich
This commit is contained in:
parent
274a7bd9a1
commit
0cf1431e5d
@ -568,7 +568,7 @@ _bufferevent_decref_and_unlock(struct bufferevent *bufev)
|
||||
EVTHREAD_LOCKTYPE_RECURSIVE);
|
||||
|
||||
/* Free the actual allocated memory. */
|
||||
mm_free(bufev - bufev->be_ops->mem_offset);
|
||||
mm_free(((char*)bufev) - bufev->be_ops->mem_offset);
|
||||
|
||||
/* Release the reference to underlying now that we no longer need the
|
||||
* reference to it. We wait this long mainly in case our lock is
|
||||
|
Loading…
x
Reference in New Issue
Block a user