From: navarrop Date: Tue, 6 Jul 2010 14:06:51 +0000 (+0000) Subject: [From Arnaud Giersch] Fix memory leak when MSG_create_environment() or X-Git-Tag: v3_5~838 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8e9c7516c266b72ebec5a0f14582932619ddda02 [From Arnaud Giersch] Fix memory leak when MSG_create_environment() or MSG_launch_application() fail. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7979 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/simix/smx_deployment.c b/src/simix/smx_deployment.c index 5bc26811a1..31cd8fdb45 100644 --- a/src/simix/smx_deployment.c +++ b/src/simix/smx_deployment.c @@ -119,6 +119,7 @@ static void parse_process_finalize(void) */ void SIMIX_launch_application(const char *file) { + int parse_status; xbt_assert0(simix_global, "SIMIX_global_init has to be called before SIMIX_launch_application."); surf_parse_reset_parser(); @@ -128,8 +129,9 @@ void SIMIX_launch_application(const char *file) surfxml_add_callback(ETag_surfxml_process_cb_list, parse_process_finalize); surf_parse_open(file); - xbt_assert1((!surf_parse()), "Parse error in %s", file); + parse_status = surf_parse(); surf_parse_close(); + xbt_assert1(!parse_status, "Parse error in %s", file); } /** diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index f312e78858..7ff2efa4c1 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -437,13 +437,14 @@ void surf_parse_open(const char *file) } return; } + surf_file_to_parse = surf_fopen(file, "r"); + xbt_assert1((surf_file_to_parse), "Unable to open \"%s\"\n", file); + if (!surf_input_buffer_stack) surf_input_buffer_stack = xbt_dynar_new(sizeof(YY_BUFFER_STATE), NULL); if (!surf_file_to_parse_stack) surf_file_to_parse_stack = xbt_dynar_new(sizeof(FILE *), NULL); - surf_file_to_parse = surf_fopen(file, "r"); - xbt_assert1((surf_file_to_parse), "Unable to open \"%s\"\n", file); surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, 10); surf_parse__switch_to_buffer(surf_input_buffer); surf_parse_lineno = 1; @@ -608,11 +609,15 @@ static void free_data(void) void parse_platform_file(const char *file) { + int parse_status; surf_parse_open(file); init_data(); - xbt_assert1((!(*surf_parse) ()), "Parse error in %s", file); + parse_status = surf_parse(); free_data(); surf_parse_close(); + if (parse_status) + xbt_dict_free(&random_data_list); + xbt_assert1(!parse_status, "Parse error in %s", file); } /* Functions to bypass route tag. Used by the route:multi tag */