diff options
author | Marcus Sundberg <marcus@marcussundberg.com> | 2016-03-26 20:11:43 +0100 |
---|---|---|
committer | Marcus Sundberg <marcus@marcussundberg.com> | 2016-03-26 20:52:07 +0100 |
commit | a8769ef12d7e223e33fc47bed03fba2bfa2f3536 (patch) | |
tree | ce7cde355c30d67f5e15c52ad221bc03aeb9d996 /buffer.c | |
parent | d5ee7391530890127eaff784d102ec6caaf258f6 (diff) | |
download | libevent-a8769ef12d7e223e33fc47bed03fba2bfa2f3536.tar.gz |
evbuffer_add: Use last_with_datap if set, not last.
evbuffer_add() would always put data in the last chain, even if there
was available space in a previous chain, and in doing so it also
failed to update last_with_datap, causing subsequent calls to other
functions that do look at last_with_datap to add data in the middle
of the evbuffer instead of at the end.
Fixes the evbuffer_add() part of issue #335, and the evbuffer/add2 and
evbuffer/add3 tests, and also prevents wasting space available in the
chain pointed to by last_with_datap.
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -1732,7 +1732,11 @@ evbuffer_add(struct evbuffer *buf, const void *data_in, size_t datlen) goto done; } - chain = buf->last; + if (*buf->last_with_datap == NULL) { + chain = buf->last; + } else { + chain = *buf->last_with_datap; + } /* If there are no chains allocated for this buffer, allocate one * big enough to hold all the data. */ |