Fix a memory leak when appending/prepending to a buffer with unused space.

This commit is contained in:
Nick Mathewson 2010-03-31 12:03:43 -04:00
parent 8e227b04da
commit 45068a312c

View File

@ -701,7 +701,9 @@ evbuffer_add_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf)
}
if (out_total_len == 0) {
/* XXX need to free old outbuf chains */
/* There might be an empty chain at the start of outbuf; free
* it. */
evbuffer_free_all_chains(outbuf->first);
COPY_CHAIN(outbuf, inbuf);
} else {
APPEND_CHAIN(outbuf, inbuf);
@ -740,7 +742,9 @@ evbuffer_prepend_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf)
}
if (out_total_len == 0) {
/* XXX need to free old outbuf chains */
/* There might be an empty chain at the start of outbuf; free
* it. */
evbuffer_free_all_chains(outbuf->first);
COPY_CHAIN(outbuf, inbuf);
} else {
PREPEND_CHAIN(outbuf, inbuf);