Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make sure we don't went out of the string to handle *before* using it (thx valgrind)
[simgrid.git] / src / xbt / xbt_str.c
index 11a50b8..aa61389 100644 (file)
@@ -60,7 +60,7 @@ xbt_str_rtrim(char* s, const char* char_list)
        while(*cur)
                ++cur;
 
-       while(white_char[(unsigned char)*cur] && (cur >= s))
+       while((cur >= s) && white_char[(unsigned char)*cur])
                --cur;
 
        *++cur = '\0';
@@ -108,7 +108,7 @@ xbt_str_ltrim( char* s, const char* char_list)
        while(*cur && white_char[(unsigned char)*cur])
                ++cur;
 
-       return strcpy(s,cur);
+       return memmove(s,cur, strlen(cur));
 }
 
 /**  @brief Strip whitespace (or other characters) from the end and the begining of a string.