mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
fix another underflow in keeping stats
these size_ts are subtle buggers svn:r4364
This commit is contained in:
+4
-2
@@ -188,7 +188,8 @@ static void buf_resize(buf_t *buf, size_t new_capacity)
|
||||
SET_GUARDS(buf->mem, new_capacity);
|
||||
buf->cur = buf->mem+offset;
|
||||
}
|
||||
buf_total_alloc += (new_capacity - buf->len);
|
||||
buf_total_alloc += new_capacity;
|
||||
buf_total_alloc -= buf->len;
|
||||
|
||||
if (offset + buf->datalen > buf->len) {
|
||||
/* We need to move data now that we are done growing. The buffer
|
||||
@@ -673,7 +674,8 @@ write_to_buf(const char *string, size_t string_len, buf_t *buf)
|
||||
}
|
||||
if (buf->datalen > buf->highwater)
|
||||
buf->highwater = buf->datalen;
|
||||
log_fn(LOG_DEBUG,"added %d bytes to buf (now %d total).",(int)string_len, (int)buf->datalen);
|
||||
log_fn(LOG_DEBUG,"added %d bytes to buf (now %d total).",
|
||||
(int)string_len, (int)buf->datalen);
|
||||
check();
|
||||
return buf->datalen;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user