mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Fix a memory leak when appending/prepending to a buffer with unused space.
This commit is contained in:
parent
8e227b04da
commit
45068a312c
8
buffer.c
8
buffer.c
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user