(mu_tilde_expansion): Bugfix. Was freeing passed homedir, which caused grief later.
Showing
1 changed file
with
6 additions
and
3 deletions
... | @@ -351,6 +351,7 @@ char * | ... | @@ -351,6 +351,7 @@ char * |
351 | mu_tilde_expansion (const char *ref, const char *delim, const char *homedir) | 351 | mu_tilde_expansion (const char *ref, const char *delim, const char *homedir) |
352 | { | 352 | { |
353 | char *p = strdup (ref); | 353 | char *p = strdup (ref); |
354 | char *home = NULL; | ||
354 | 355 | ||
355 | if (*p == '~') | 356 | if (*p == '~') |
356 | { | 357 | { |
... | @@ -360,16 +361,16 @@ mu_tilde_expansion (const char *ref, const char *delim, const char *homedir) | ... | @@ -360,16 +361,16 @@ mu_tilde_expansion (const char *ref, const char *delim, const char *homedir) |
360 | char *s; | 361 | char *s; |
361 | if (!homedir) | 362 | if (!homedir) |
362 | { | 363 | { |
363 | homedir = mu_get_homedir (); | 364 | home = mu_get_homedir (); |
364 | if (!homedir) | 365 | if (!home) |
365 | return NULL; | 366 | return NULL; |
367 | homedir = home; | ||
366 | } | 368 | } |
367 | s = calloc (strlen (homedir) + strlen (p) + 1, 1); | 369 | s = calloc (strlen (homedir) + strlen (p) + 1, 1); |
368 | strcpy (s, homedir); | 370 | strcpy (s, homedir); |
369 | strcat (s, p); | 371 | strcat (s, p); |
370 | free (--p); | 372 | free (--p); |
371 | p = s; | 373 | p = s; |
372 | free (homedir); | ||
373 | } | 374 | } |
374 | else | 375 | else |
375 | { | 376 | { |
... | @@ -397,6 +398,8 @@ mu_tilde_expansion (const char *ref, const char *delim, const char *homedir) | ... | @@ -397,6 +398,8 @@ mu_tilde_expansion (const char *ref, const char *delim, const char *homedir) |
397 | p--; | 398 | p--; |
398 | } | 399 | } |
399 | } | 400 | } |
401 | if (home) | ||
402 | free (home); | ||
400 | return p; | 403 | return p; |
401 | } | 404 | } |
402 | 405 | ... | ... |
-
Please register or sign in to post a comment