Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix memory leak in xbt_cfg_set_parse().
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Mon, 7 Nov 2011 22:04:05 +0000 (23:04 +0100)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 8 Nov 2011 14:13:09 +0000 (15:13 +0100)
src/xbt/config.c

index 13df108..9fbffa5 100644 (file)
@@ -660,10 +660,17 @@ void xbt_cfg_set_parse(xbt_cfg_t cfg, const char *options)
     CATCH(e) {
       if (e.category == not_found_error) {
         xbt_ex_free(e);
-        name = xbt_strdup(name);
-        free(optionlist_cpy);
-        THROWF(not_found_error, 0,
-               "No registered variable corresponding to '%s'.", name);
+        TRY {
+          THROWF(not_found_error, 0,
+                 "No registered variable corresponding to '%s'.", name);
+        }
+        TRY_CLEANUP {
+          /* name points into optionlist_cpy, it cannot be freed before */
+          free(optionlist_cpy);
+        }
+        CATCH_ANONYMOUS {
+          RETHROW;
+        }
       }
       free(optionlist_cpy);
       RETHROW;