summaryrefslogtreecommitdiff
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
authorJason Parker <jparker@digium.com>2012-02-10 22:44:12 +0000
committerJason Parker <jparker@digium.com>2012-02-10 22:44:12 +0000
commit6749b6e2be9250489dc06cf4868b311d7912fc3e (patch)
tree61e517c4f7ab0212f0e31f3ae9678fe39374b8f0 /apps/app_voicemail.c
parent8af49f158a03de3fd54be592677cce31a9749232 (diff)
Fix a voicemail memory leak with heard/deleted messages.
open_mailbox() was changed quite a long time ago to allocate this memory. close_mailbox() should have been changed to be responsible for freeing it. ........ Merged revisions 354889 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 354890 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@354903 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r--apps/app_voicemail.c23
1 files changed, 4 insertions, 19 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index b5d62db09..2b518a23e 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -8133,11 +8133,11 @@ static int close_mailbox(struct vm_state *vms, struct ast_vm_user *vmu)
#endif
done:
- if (vms->deleted && vmu->maxmsg) {
- memset(vms->deleted, 0, vms->dh_arraysize * sizeof(int));
+ if (vms->deleted) {
+ ast_free(vms->deleted);
}
- if (vms->heard && vmu->maxmsg) {
- memset(vms->heard, 0, vms->dh_arraysize * sizeof(int));
+ if (vms->heard) {
+ ast_free(vms->heard);
}
return 0;
@@ -10126,17 +10126,6 @@ static int vm_execmain(struct ast_channel *chan, const char *data)
vmstate_insert(&vms);
init_vm_state(&vms);
#endif
- /* Avoid allocating a buffer of 0 bytes, because some platforms really don't like that. */
- if (!(vms.deleted = ast_calloc(vmu->maxmsg ? vmu->maxmsg : 1, sizeof(int)))) {
- ast_log(AST_LOG_ERROR, "Could not allocate memory for deleted message storage!\n");
- cmd = ast_play_and_wait(chan, "an-error-has-occured");
- return -1;
- }
- if (!(vms.heard = ast_calloc(vmu->maxmsg ? vmu->maxmsg : 1, sizeof(int)))) {
- ast_log(AST_LOG_ERROR, "Could not allocate memory for heard message storage!\n");
- cmd = ast_play_and_wait(chan, "an-error-has-occured");
- return -1;
- }
/* Set language from config to override channel language */
if (!ast_strlen_zero(vmu->language))
@@ -10719,10 +10708,6 @@ out:
#endif
if (vmu)
free_user(vmu);
- if (vms.deleted)
- ast_free(vms.deleted);
- if (vms.heard)
- ast_free(vms.heard);
#ifdef IMAP_STORAGE
pthread_setspecific(ts_vmstate.key, NULL);