(mu_mailbox_create_default): Fix memory leaks
Showing
1 changed file
with
6 additions
and
7 deletions
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | 1 | /* GNU Mailutils -- a suite of utilities for electronic mail |
2 | Copyright (C) 1999, 2000, 2001, 2003, 2004, | 2 | Copyright (C) 1999, 2000, 2001, 2003, 2004, |
3 | 2005, 2006 Free Software Foundation, Inc. | 3 | 2005, 2006, 2007 Free Software Foundation, Inc. |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Lesser General Public | 6 | modify it under the terms of the GNU Lesser General Public |
... | @@ -323,11 +323,9 @@ mu_mailbox_create_default (mu_mailbox_t *pmbox, const char *mail) | ... | @@ -323,11 +323,9 @@ mu_mailbox_create_default (mu_mailbox_t *pmbox, const char *mail) |
323 | 323 | ||
324 | p = mu_tilde_expansion (mail, "/", NULL); | 324 | p = mu_tilde_expansion (mail, "/", NULL); |
325 | if (tmp_mbox) | 325 | if (tmp_mbox) |
326 | { | ||
327 | free (tmp_mbox); | 326 | free (tmp_mbox); |
328 | tmp_mbox = p; | 327 | tmp_mbox = p; |
329 | } | 328 | mail = tmp_mbox; |
330 | mail = p; | ||
331 | if (!mail) | 329 | if (!mail) |
332 | return ENOMEM; | 330 | return ENOMEM; |
333 | 331 | ||
... | @@ -349,9 +347,10 @@ mu_mailbox_create_default (mu_mailbox_t *pmbox, const char *mail) | ... | @@ -349,9 +347,10 @@ mu_mailbox_create_default (mu_mailbox_t *pmbox, const char *mail) |
349 | default: | 347 | default: |
350 | if (!mu_is_proto (mail)) | 348 | if (!mu_is_proto (mail)) |
351 | { | 349 | { |
352 | tmp_mbox = mu_getcwd(); | 350 | p = mu_getcwd(); |
353 | mbox = malloc (strlen (tmp_mbox) + strlen (mail) + 2); | 351 | mbox = malloc (strlen (p) + strlen (mail) + 2); |
354 | sprintf (mbox, "%s/%s", tmp_mbox, mail); | 352 | sprintf (mbox, "%s/%s", p, mail); |
353 | free (p); | ||
355 | } | 354 | } |
356 | else | 355 | else |
357 | mbox = strdup (mail); | 356 | mbox = strdup (mail); | ... | ... |
-
Please register or sign in to post a comment