]> granicus.if.org Git - libevent/commitdiff
evbuffer: fix last_with_datap after prepend with empty chain
authorAzat Khuzhin <azat@libevent.org>
Fri, 10 May 2019 21:17:03 +0000 (00:17 +0300)
committerAzat Khuzhin <azat@libevent.org>
Thu, 16 May 2019 07:16:21 +0000 (10:16 +0300)
last_with_datap should be adjusted only if it buf->first *was* not
empty, otherwise last_with_datap should point to the prepended chain.

buffer.c

index 11b1bdae5ef0a2c6efece64bc778d66544719977..6ad8fd24ff59a70f4d82953e6818adadbc890e0a 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -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;