aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/or/buffers.c3
-rw-r--r--src/test/test.c12
2 files changed, 14 insertions, 1 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 47fa31dc07..d063d23135 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -148,7 +148,8 @@ static INLINE chunk_freelist_t *
get_freelist(size_t alloc)
{
int i;
- for (i=0; freelists[i].alloc_size <= alloc; ++i) {
+ for (i=0; (freelists[i].alloc_size <= alloc &&
+ freelists[i].alloc_size); ++i ) {
if (freelists[i].alloc_size == alloc) {
return &freelists[i];
}
diff --git a/src/test/test.c b/src/test/test.c
index c12ba93d79..0e48533978 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -813,6 +813,18 @@ test_buffers(void)
buf_free(buf);
buf = NULL;
+ /* Try adding a string too long for any freelist. */
+ {
+ char *cp = tor_malloc_zero(65536);
+ buf = buf_new();
+ write_to_buf(cp, 65536, buf);
+ tor_free(cp);
+
+ tt_int_op(buf_datalen(buf), ==, 65536);
+ buf_free(buf);
+ buf = NULL;
+ }
+
done:
if (buf)
buf_free(buf);