From: Martin Quinson Date: Sat, 4 Apr 2015 12:56:03 +0000 (+0200) Subject: dont segfault when exiting before everything is allocated (as on parse errors) X-Git-Tag: v3_12~738^2~15 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/59ba73ddb4a68bea5e1a99f21a4d5d12587b6288 dont segfault when exiting before everything is allocated (as on parse errors) --- diff --git a/src/surf/surf_routing_floyd.cpp b/src/surf/surf_routing_floyd.cpp index 7d4e9423f8..e87df4f4e7 100644 --- a/src/surf/surf_routing_floyd.cpp +++ b/src/surf/surf_routing_floyd.cpp @@ -33,16 +33,19 @@ AsFloyd::~AsFloyd(){ int i, j; int table_size; table_size = (int)xbt_dynar_length(p_indexNetworkElm); - /* Delete link_table */ - for (i = 0; i < table_size; i++) - for (j = 0; j < table_size; j++) - generic_free_route(TO_FLOYD_LINK(i, j)); - xbt_free(p_linkTable); - /* Delete bypass dict */ - xbt_dict_free(&p_bypassRoutes); - /* Delete predecessor and cost table */ - xbt_free(p_predecessorTable); - xbt_free(p_costTable); + if (p_linkTable == NULL) // Dealing with a parse error in the file? + return; + /* Delete link_table */ + for (i = 0; i < table_size; i++) + for (j = 0; j < table_size; j++) { + generic_free_route(TO_FLOYD_LINK(i, j)); + } + xbt_free(p_linkTable); + /* Delete bypass dict */ + xbt_dict_free(&p_bypassRoutes); + /* Delete predecessor and cost table */ + xbt_free(p_predecessorTable); + xbt_free(p_costTable); } /* Business methods */