Merged revisions 62545 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r62545 | tilghman | 2007-05-01 16:34:43 -0500 (Tue, 01 May 2007) | 2 lines

Bug 9590 - Memory leaks around find_user() (found by rayjay, different fixes by me)

........


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@62546 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.6.0
Tilghman Lesher 19 years ago
parent 32ca8db474
commit 2059f767dd

@ -2642,6 +2642,7 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
/* No IMAP account available */ /* No IMAP account available */
if (vmu->imapuser[0] == '\0') { if (vmu->imapuser[0] == '\0') {
ast_log (LOG_WARNING,"IMAP user not set for mailbox %s\n",vmu->mailbox); ast_log (LOG_WARNING,"IMAP user not set for mailbox %s\n",vmu->mailbox);
free_user(vmu);
return -1; return -1;
} }
@ -2651,6 +2652,7 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
ast_log (LOG_DEBUG,"Returning before search - user is logged in\n"); ast_log (LOG_DEBUG,"Returning before search - user is logged in\n");
*newmsgs = vms_p->newmessages; *newmsgs = vms_p->newmessages;
*oldmsgs = vms_p->oldmessages; *oldmsgs = vms_p->oldmessages;
free_user(vmu);
return 0; return 0;
} }
@ -2658,8 +2660,10 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
if (!(vms_p = get_vm_state_by_imapuser(vmu->imapuser, 0)) && !(vms_p = get_vm_state_by_mailbox(mailboxnc, 0))) { if (!(vms_p = get_vm_state_by_imapuser(vmu->imapuser, 0)) && !(vms_p = get_vm_state_by_mailbox(mailboxnc, 0))) {
if(option_debug > 2) if(option_debug > 2)
ast_log (LOG_DEBUG,"Adding new vmstate for %s\n",vmu->imapuser); ast_log (LOG_DEBUG,"Adding new vmstate for %s\n",vmu->imapuser);
if (!(vms_p = ast_calloc(1, sizeof(*vms_p)))) if (!(vms_p = ast_calloc(1, sizeof(*vms_p)))) {
free_user(vmu);
return -1; return -1;
}
ast_copy_string(vms_p->imapuser,vmu->imapuser, sizeof(vms_p->imapuser)); ast_copy_string(vms_p->imapuser,vmu->imapuser, sizeof(vms_p->imapuser));
ast_copy_string(vms_p->username, mailboxnc, sizeof(vms_p->username)); /* save for access from interactive entry point */ ast_copy_string(vms_p->username, mailboxnc, sizeof(vms_p->username)); /* save for access from interactive entry point */
vms_p->mailstream = NIL; /* save for access from interactive entry point */ vms_p->mailstream = NIL; /* save for access from interactive entry point */
@ -2676,6 +2680,7 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
ret = init_mailstream(vms_p, 0); ret = init_mailstream(vms_p, 0);
if (!vms_p->mailstream) { if (!vms_p->mailstream) {
ast_log (LOG_ERROR,"Houston we have a problem - IMAP mailstream is NULL\n"); ast_log (LOG_ERROR,"Houston we have a problem - IMAP mailstream is NULL\n");
free_user(vmu);
return -1; return -1;
} }
@ -2721,6 +2726,7 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
*oldmsgs = vms_p->oldmessages; *oldmsgs = vms_p->oldmessages;
} }
free_user(vmu);
return 0; return 0;
} }
@ -8380,7 +8386,8 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s
ast_config_destroy(msg_cfg); ast_config_destroy(msg_cfg);
return res; return res;
} else { } else {
if (find_user(NULL, vmu->context, num)) { struct ast_vm_user vmu2;
if (find_user(&vmu2, vmu->context, num)) {
struct leave_vm_options leave_options; struct leave_vm_options leave_options;
char mailbox[AST_MAX_EXTENSION * 2 + 2]; char mailbox[AST_MAX_EXTENSION * 2 + 2];
snprintf(mailbox, sizeof(mailbox), "%s@%s", num, vmu->context); snprintf(mailbox, sizeof(mailbox), "%s@%s", num, vmu->context);

Loading…
Cancel
Save