Commit 0282f3bf 0282f3bfc15a364aebaea91197df6b5e658d7d9a by Sergey Poznyakoff

Avoid unnecessary memory allocation.

1 parent 0b2a01ec
...@@ -261,7 +261,7 @@ switch_user_id (struct mu_auth_data *auth, int user) ...@@ -261,7 +261,7 @@ switch_user_id (struct mu_auth_data *auth, int user)
261 int rc; 261 int rc;
262 uid_t uid; 262 uid_t uid;
263 263
264 if (auth->change_uid == 0) 264 if (!auth || auth->change_uid == 0)
265 return 0; 265 return 0;
266 266
267 if (user) 267 if (user)
...@@ -375,22 +375,13 @@ deliver (FILE *fp, char *name) ...@@ -375,22 +375,13 @@ deliver (FILE *fp, char *name)
375 return; 375 return;
376 } 376 }
377 377
378 path = strdup (auth->mailbox); 378 if ((status = mailbox_create (&mbox, auth->mailbox)) != 0)
379 if (!path)
380 { 379 {
381 mailer_err ("Out of memory"); 380 mailer_err ("can't open mailbox %s: %s",
381 auth->mailbox, mu_errstring (status));
382 return; 382 return;
383 } 383 }
384 384
385 if ((status = mailbox_create (&mbox, path)) != 0)
386 {
387 mailer_err ("can't open mailbox %s: %s", path, mu_errstring (status));
388 free (path);
389 return;
390 }
391
392 free (path);
393
394 mailbox_get_url (mbox, &url); 385 mailbox_get_url (mbox, &url);
395 path = (char*) url_to_string (url); 386 path = (char*) url_to_string (url);
396 387
......