Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Fix pointer dereference after free()
authorGabriel Corona <gabriel.corona@enst-bretagne.fr>
Tue, 2 Jun 2015 19:11:30 +0000 (21:11 +0200)
committerGabriel Corona <gabriel.corona@enst-bretagne.fr>
Tue, 2 Jun 2015 19:13:40 +0000 (21:13 +0200)
src/mc/memory_map.cpp

index f80105c..52bfa70 100644 (file)
@@ -27,11 +27,11 @@ std::vector<VmMap> get_memory_map(pid_t pid)
   /* to be returned. */
   char* path = bprintf("/proc/%i/maps", (int) pid);
   FILE *fp = fopen(path, "r");
-  free(path);
   if(fp == NULL)
     perror("fopen failed");
   xbt_assert(fp,
     "Cannot open %s to investigate the memory map of the process.", path);
+  free(path);
   setbuf(fp, NULL);
 
   std::vector<VmMap> ret;