mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
fix an evbuffer corruption when adding an empty evbuffer; from Scott Lamb
svn:r845
This commit is contained in:
parent
480d8142b8
commit
9586a1cbb0
3
buffer.c
3
buffer.c
@ -196,6 +196,9 @@ evbuffer_add_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf)
|
||||
size_t out_total_len = outbuf->total_len;
|
||||
size_t in_total_len = inbuf->total_len;
|
||||
|
||||
if (in_total_len == 0)
|
||||
return (0);
|
||||
|
||||
if (out_total_len == 0) {
|
||||
COPY_CHAIN(outbuf, inbuf);
|
||||
} else {
|
||||
|
@ -985,6 +985,9 @@ test_evbuffer(void)
|
||||
memcmp((char*)EVBUFFER_DATA(evb), "hello/1", 1) != 0)
|
||||
goto out;
|
||||
|
||||
evbuffer_add_buffer(evb, evb_two);
|
||||
evbuffer_validate(evb);
|
||||
|
||||
evbuffer_drain(evb, strlen("hello/"));
|
||||
evbuffer_validate(evb);
|
||||
if (EVBUFFER_LENGTH(evb) != 1 ||
|
||||
|
Loading…
x
Reference in New Issue
Block a user