Minor fix in libstring
* libmailutils/string/mkfilename.c (mu_make_file_name_suf): Don't add leading / if dir=="".
Showing
1 changed file
with
3 additions
and
2 deletions
... | @@ -36,12 +36,13 @@ mu_make_file_name_suf (const char *dir, const char *file, const char *suf) | ... | @@ -36,12 +36,13 @@ mu_make_file_name_suf (const char *dir, const char *file, const char *suf) |
36 | while (dirlen > 0 && dir[dirlen-1] == '/') | 36 | while (dirlen > 0 && dir[dirlen-1] == '/') |
37 | dirlen--; | 37 | dirlen--; |
38 | 38 | ||
39 | len = dirlen + 1 + fillen + suflen; | 39 | len = dirlen + (dir[0] ? 1 : 0) + fillen + suflen; |
40 | tmp = mu_alloc (len + 1); | 40 | tmp = mu_alloc (len + 1); |
41 | if (tmp) | 41 | if (tmp) |
42 | { | 42 | { |
43 | memcpy (tmp, dir, dirlen); | 43 | memcpy (tmp, dir, dirlen); |
44 | tmp[dirlen++] = '/'; | 44 | if (dir[0]) |
45 | tmp[dirlen++] = '/'; | ||
45 | memcpy (tmp + dirlen, file, fillen); | 46 | memcpy (tmp + dirlen, file, fillen); |
46 | if (suf) | 47 | if (suf) |
47 | memcpy (tmp + dirlen + fillen, suf, suflen); | 48 | memcpy (tmp + dirlen + fillen, suf, suflen); | ... | ... |
-
Please register or sign in to post a comment