Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : fix memory free
[simgrid.git] / src / mc / mc_compare.c
index 07550eb..36ff8b9 100644 (file)
@@ -539,8 +539,10 @@ static int compare_local_variables(char *s1, char *s2, xbt_dynar_t heap_equals){
     s_tokens2 = xbt_str_split(xbt_dynar_get_as(tokens2, cursor, char *), "=");
     if(xbt_dynar_length(s_tokens1) > 1 && xbt_dynar_length(s_tokens2) > 1){
       if((strcmp(xbt_dynar_get_as(s_tokens1, 0, char *), "ip") == 0) && (strcmp(xbt_dynar_get_as(s_tokens2, 0, char *), "ip") == 0)){
-        ip1 = xbt_dynar_get_as(s_tokens1, 1, char *);
-        ip2 = xbt_dynar_get_as(s_tokens2, 1, char *);
+        xbt_free(ip1);
+        xbt_free(ip2);
+        ip1 = strdup(xbt_dynar_get_as(s_tokens1, 1, char *));
+        ip2 = strdup(xbt_dynar_get_as(s_tokens2, 1, char *));
       }
       if(strcmp(xbt_dynar_get_as(s_tokens1, 1, char *), xbt_dynar_get_as(s_tokens2, 1, char *)) != 0){   
         /* Ignore this variable ?  */
@@ -559,15 +561,20 @@ static int compare_local_variables(char *s1, char *s2, xbt_dynar_t heap_equals){
           xbt_dynar_free(&s_tokens2);
           xbt_dynar_free(&tokens1);
           xbt_dynar_free(&tokens2);
+          xbt_free(ip1);
+          xbt_free(ip2);
           return 1;
         }
       }
     }
     xbt_dynar_free(&s_tokens1);
     xbt_dynar_free(&s_tokens2);
+         
     cursor++;
   }
 
+  xbt_free(ip1);
+  xbt_free(ip2);
   xbt_dynar_free(&tokens1);
   xbt_dynar_free(&tokens2);
   return 0;