Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
[simgrid.git] / src / xbt / mmalloc / mm_legacy.c
index f7d0f71..96610ee 100644 (file)
@@ -69,11 +69,13 @@ void *realloc(void *p, size_t s)
 
 void free(void *p)
 {
-  xbt_mheap_t mdp = __mmalloc_current_heap ?: (xbt_mheap_t) mmalloc_preinit();
+  if (p != NULL) {
+    xbt_mheap_t mdp = __mmalloc_current_heap ?: (xbt_mheap_t) mmalloc_preinit();
 
-  LOCK(mdp);
-  mfree(mdp, p);
-  UNLOCK(mdp);
+    LOCK(mdp);
+    mfree(mdp, p);
+    UNLOCK(mdp);
+  }
 }
 #endif