aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-05-01 21:34:43 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-05-01 21:34:43 +0000
commitc7c3f6020c0c3dc3a0d7856fbf801db68bfa59da (patch)
tree8b2d5a8496bf6a184c6faadca3a9e361a13ada11 /apps
parent8abc160ed1972fc897a2962c8c985b373f3ac288 (diff)
Bug 9590 - Memory leaks around find_user() (found by rayjay, different fixes by me)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@62545 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_voicemail.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index fe37ec717..615178912 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -2498,6 +2498,7 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
/* No IMAP account available */
if (vmu->imapuser[0] == '\0') {
ast_log (LOG_WARNING,"IMAP user not set for mailbox %s\n",vmu->mailbox);
+ free_user(vmu);
return -1;
}
}
@@ -2512,6 +2513,7 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
ast_log (LOG_DEBUG,"Returning before search - user is logged in\n");
*newmsgs = vms_p->newmessages;
*oldmsgs = vms_p->oldmessages;
+ free_user(vmu);
return 0;
}
@@ -2524,8 +2526,10 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
if (!vms_p) {
if(option_debug > 2)
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;
+ }
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 */
vms_p->mailstream = NIL; /* save for access from interactive entry point */
@@ -2540,6 +2544,7 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
ret = init_mailstream(vms_p, 0);
if (!vms_p->mailstream) {
ast_log (LOG_ERROR,"IMAP mailstream is NULL\n");
+ free_user(vmu);
return -1;
}
if (newmsgs && ret==0 && vms_p->updated==1 ) {
@@ -2584,6 +2589,7 @@ static int inboxcount(const char *mailbox, int *newmsgs, int *oldmsgs)
*newmsgs = vms_p->newmessages;
*oldmsgs = vms_p->oldmessages;
}
+ free_user(vmu);
return 0;
}
@@ -7936,7 +7942,8 @@ static int advanced_options(struct ast_channel *chan, struct ast_vm_user *vmu, s
ast_config_destroy(msg_cfg);
return res;
} 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;
char mailbox[AST_MAX_EXTENSION * 2 + 2];
snprintf(mailbox, sizeof(mailbox), "%s@%s", num, vmu->context);