[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r19074: {tor} Add some asserts to try to catch bug 930 (tor/trunk/src/common)



Author: nickm
Date: 2009-03-18 11:12:56 -0400 (Wed, 18 Mar 2009)
New Revision: 19074

Modified:
   tor/trunk/src/common/memarea.c
Log:
Add some asserts to try to catch bug 930

Modified: tor/trunk/src/common/memarea.c
===================================================================
--- tor/trunk/src/common/memarea.c	2009-03-18 14:35:24 UTC (rev 19073)
+++ tor/trunk/src/common/memarea.c	2009-03-18 15:12:56 UTC (rev 19074)
@@ -31,6 +31,7 @@
 {
   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 @@
     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 @@
   }
   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;
 }