fix an evbuffer corruption when adding an empty evbuffer; from Scott Lamb

svn:r845
This commit is contained in:
Niels Provos 2008-06-01 16:21:24 +00:00
parent 480d8142b8
commit 9586a1cbb0
2 changed files with 6 additions and 0 deletions

View File

@ -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 {

View File

@ -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 ||