Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
improve the mmalloc tesh to ensure that use after free don't ruin mmalloc
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 16 Oct 2012 16:18:27 +0000 (18:18 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 16 Oct 2012 16:18:45 +0000 (18:18 +0200)
teshsuite/xbt/mmalloc.tesh
teshsuite/xbt/mmalloc_test.c

index 6e36d34..4656155 100644 (file)
@@ -102,6 +102,7 @@ $ ./xbt/mmalloc_test --log=root.fmt:%m%n
 > 4900 bytes allocated with offset 1cc000
 > 5000 bytes allocated with offset 1ce000
 > All blocks were correctly allocated. Free every second block
 > 4900 bytes allocated with offset 1cc000
 > 5000 bytes allocated with offset 1ce000
 > All blocks were correctly allocated. Free every second block
+> Memset every second block to zero (yeah, they are not currently allocated :)
 > Re-allocate every second block
 > free all blocks (each one twice, to check that double free are correctly catched)
 > free again all blocks (to really check that double free are correctly catched)
 > Re-allocate every second block
 > free all blocks (each one twice, to check that double free are correctly catched)
 > free again all blocks (to really check that double free are correctly catched)
index 2973248..cc70aa6 100644 (file)
@@ -41,6 +41,11 @@ int main(int argc, char**argv)
     size = size_of_block(i);
     mfree(heapA,pointers[i]);
   }
     size = size_of_block(i);
     mfree(heapA,pointers[i]);
   }
+  XBT_INFO("Memset every second block to zero (yeah, they are not currently allocated :)");
+  for (i = 0; i < TESTSIZE; i+=2) {
+    size = size_of_block(i);
+    memset(pointers[i],0, size);
+  }
   XBT_INFO("Re-allocate every second block");
   for (i = 0; i < TESTSIZE; i+=2) {
     size = size_of_block(i);
   XBT_INFO("Re-allocate every second block");
   for (i = 0; i < TESTSIZE; i+=2) {
     size = size_of_block(i);