aboutsummaryrefslogtreecommitdiff
path: root/src/common/memarea.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-03-18 15:12:56 +0000
committerNick Mathewson <nickm@torproject.org>2009-03-18 15:12:56 +0000
commitcb3b95de194d34f3c9a43392dadf0f2a421a4612 (patch)
tree3cac41c96165f7273a2b5fb514e12e3b896e1049 /src/common/memarea.c
parent30ec1d1d50860241c1c4fa1dccd3ff3cde32691a (diff)
downloadtor-cb3b95de194d34f3c9a43392dadf0f2a421a4612.tar
tor-cb3b95de194d34f3c9a43392dadf0f2a421a4612.tar.gz
Add some asserts to try to catch bug 930
svn:r19074
Diffstat (limited to 'src/common/memarea.c')
-rw-r--r--src/common/memarea.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/common/memarea.c b/src/common/memarea.c
index b99ced135..65e36e3dd 100644
--- a/src/common/memarea.c
+++ b/src/common/memarea.c
@@ -31,6 +31,7 @@ realign_pointer(void *ptr)
{
uintptr_t x = (uintptr_t)ptr;
x = (x+MEMAREA_ALIGN_MASK) & ~MEMAREA_ALIGN_MASK;
+ tor_assert(((void*)x) >= ptr); // XXXX021 remove this once bug 930 is solved
return (void*)x;
}
@@ -84,6 +85,8 @@ alloc_chunk(size_t sz, int freelist_ok)
res->next_chunk = NULL;
res->mem_size = chunk_size - CHUNK_HEADER_SIZE;
res->next_mem = res->u.mem;
+ tor_assert(res->next_mem+res->mem_size == ((char*)res)+chunk_size);
+ tor_assert(realign_pointer(res->next_mem) == res->next_mem);
return res;
}
}
@@ -196,6 +199,9 @@ memarea_alloc(memarea_t *area, size_t sz)
}
result = chunk->next_mem;
chunk->next_mem = realign_pointer(chunk->next_mem + sz);
+ // XXXX021 remove these once bug 930 is solved.
+ tor_assert(chunk->next_mem >= chunk->u.mem);
+ tor_assert(chunk->next_mem <= chunk->u.mem+chunk->mem_size);
return result;
}