From: Gabriel Corona Date: Wed, 23 Mar 2016 12:08:29 +0000 (+0100) Subject: [mc] Fix a leak in simgrid-mc X-Git-Tag: v3_13~327^2 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/28e3d706d2b879fc7e84f569cd8cd72a86e0c550?ds=inline [mc] Fix a leak in simgrid-mc --- diff --git a/src/mc/simgrid_mc.cpp b/src/mc/simgrid_mc.cpp index 8c48f73349..b8b4b08e76 100644 --- a/src/mc/simgrid_mc.cpp +++ b/src/mc/simgrid_mc.cpp @@ -32,7 +32,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_main, mc, "Entry point for simgrid-mc"); -static +static inline char** argvdup(int argc, char** argv) { char** argv_copy = xbt_new(char*, argc+1); @@ -75,15 +75,16 @@ int main(int argc, char** argv) mc_mode = MC_MODE_SERVER; // The initialisation function can touch argv. - // We need to keep the original parameters in order to pass them to the - // model-checked process so we make a copy of them: - int argc_copy = argc; + // We make a copy of argv before modifying it in order to pass the original + // value to the model-checked: char** argv_copy = argvdup(argc, argv); - xbt_log_init(&argc_copy, argv_copy); - sg_config_init(&argc_copy, argv_copy); + xbt_log_init(&argc, argv); + sg_config_init(&argc, argv); std::unique_ptr session = - std::unique_ptr(Session::spawnvp(argv[1], argv+1)); + std::unique_ptr(Session::spawnvp(argv_copy[1], argv_copy+1)); + free(argv_copy); + simgrid::mc::session = session.get(); std::unique_ptr checker = createChecker(*session); int res = checker->run();