evbuffer: fix last_with_datap after prepend with empty chain

last_with_datap should be adjusted only if it buf->first *was* not
empty, otherwise last_with_datap should point to the prepended chain.
This commit is contained in:
Azat Khuzhin 2019-05-11 00:17:03 +03:00
parent 244cacaf8c
commit 401bd1c09e
No known key found for this signature in database
GPG Key ID: B86086848EF8686D

View File

@ -1905,7 +1905,7 @@ evbuffer_prepend(struct evbuffer *buf, const void *data, size_t datlen)
if ((tmp = evbuffer_chain_new(datlen)) == NULL)
goto done;
buf->first = tmp;
if (buf->last_with_datap == &buf->first)
if (buf->last_with_datap == &buf->first && chain->off)
buf->last_with_datap = &tmp->next;
tmp->next = chain;