From: Martin Quinson Date: Tue, 16 Oct 2012 16:18:27 +0000 (+0200) Subject: improve the mmalloc tesh to ensure that use after free don't ruin mmalloc X-Git-Tag: v3_8~52 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/7989355dfec335e1c7abea0ea90a85dab4a51513 improve the mmalloc tesh to ensure that use after free don't ruin mmalloc --- diff --git a/teshsuite/xbt/mmalloc.tesh b/teshsuite/xbt/mmalloc.tesh index 6e36d340dd..4656155195 100644 --- a/teshsuite/xbt/mmalloc.tesh +++ b/teshsuite/xbt/mmalloc.tesh @@ -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 +> 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) diff --git a/teshsuite/xbt/mmalloc_test.c b/teshsuite/xbt/mmalloc_test.c index 2973248566..cc70aa6ee4 100644 --- a/teshsuite/xbt/mmalloc_test.c +++ b/teshsuite/xbt/mmalloc_test.c @@ -41,6 +41,11 @@ int main(int argc, char**argv) 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);