aboutsummaryrefslogtreecommitdiff
path: root/src/or/buffers.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-05-02 23:32:23 +0000
committerNick Mathewson <nickm@torproject.org>2005-05-02 23:32:23 +0000
commitd6a6c8785bb8b126d0b87aa900623fb9d019ab60 (patch)
tree94f776a05d9be538e91d6d91e85e46a58570bd14 /src/or/buffers.c
parenta312ce1d3b77522b08e91e1524c91e9dfb05f90a (diff)
downloadtor-d6a6c8785bb8b126d0b87aa900623fb9d019ab60.tar.gz
tor-d6a6c8785bb8b126d0b87aa900623fb9d019ab60.zip
When removing all bytes from a buffer, reset buf->cur=buf->mem
svn:r4166
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r--src/or/buffers.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 8aaa962dec..8648c30786 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -267,7 +267,11 @@ buf_shrink(buf_t *buf)
static INLINE void buf_remove_from_front(buf_t *buf, size_t n) {
tor_assert(buf->datalen >= n);
buf->datalen -= n;
- buf->cur = _wrap_ptr(buf, buf->cur+n);
+ if (buf->datalen) {
+ buf->cur = _wrap_ptr(buf, buf->cur+n);
+ } else {
+ buf->cur = buf->mem;
+ }
buf_shrink_if_underfull(buf);
check();
}