Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
checks that double free are correctly detected
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 8 Oct 2012 23:01:16 +0000 (01:01 +0200)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 8 Oct 2012 23:02:04 +0000 (01:02 +0200)
teshsuite/xbt/mmalloc_test.c

index 30e0994..dc1e6d9 100644 (file)
@@ -37,7 +37,18 @@ int main(int argc, char**argv)
   }
 
   for (i = 0; i < TESTSIZE; i++) {
   }
 
   for (i = 0; i < TESTSIZE; i++) {
+    xbt_ex_t e;
+    int gotit = 1;
+
     mfree(heapA, pointers[i]);
     mfree(heapA, pointers[i]);
+    TRY {
+      mfree(heapA, pointers[i]);
+      gotit = 0;
+    } CATCH(e) {
+      xbt_ex_free(e);
+    }
+    if (!gotit)
+      xbt_die("FAIL: A double-free went undetected (for size:%d)",((i%10)+1)*100);
   }
 
   XBT_INFO("Done; bye bye");
   }
 
   XBT_INFO("Done; bye bye");