[asterisk-commits] mjordan: branch 1.8 r372268 - /branches/1.8/apps/app_voicemail.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Sep 5 08:13:39 CDT 2012
Author: mjordan
Date: Wed Sep 5 08:13:33 2012
New Revision: 372268
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=372268
Log:
Fix memory leaks in app_voicemail when using IMAP storage or realtime config
This patch fixes two memory leaks:
1. When find_user is called with NULL as its first parameter, the voicemail
user returned is allocated on the heap. The inboxcount2 function uses
find_user in such a fashion when counting new messages, and fails to free
the resulting voicemail user object.
2. When populate_defaults is called on a voicemail user, it wipes whatever
flags have been set on the object by copying over the global flags object.
If the VM_ALLOCED flag was ste on the voicemail user prior to doing so,
that flag is removed. This leaks the voicemail user when free_user is later
called.
(closes issue ASTERISK-19155)
Reported by: Filip Jenicek
patches:
asterisk.patch2 uploaded by Filip Jenicek (license 6277)
Patch slightly modified for this commit.
Review: https://reviewboard.asterisk.org/r/2096
Modified:
branches/1.8/apps/app_voicemail.c
Modified: branches/1.8/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/apps/app_voicemail.c?view=diff&rev=372268&r1=372267&r2=372268
==============================================================================
--- branches/1.8/apps/app_voicemail.c (original)
+++ branches/1.8/apps/app_voicemail.c Wed Sep 5 08:13:33 2012
@@ -1407,17 +1407,21 @@
struct ast_vm_user *retval;
if ((retval = (ivm ? ivm : ast_calloc(1, sizeof(*retval))))) {
- if (!ivm)
- ast_set_flag(retval, VM_ALLOCED);
- else
+ if (ivm) {
memset(retval, 0, sizeof(*retval));
- if (mailbox)
+ }
+ populate_defaults(retval);
+ if (!ivm) {
+ ast_set_flag(retval, VM_ALLOCED);
+ }
+ if (mailbox) {
ast_copy_string(retval->mailbox, mailbox, sizeof(retval->mailbox));
- populate_defaults(retval);
- if (!context && ast_test_flag((&globalflags), VM_SEARCH))
+ }
+ if (!context && ast_test_flag((&globalflags), VM_SEARCH)) {
var = ast_load_realtime("voicemail", "mailbox", mailbox, SENTINEL);
- else
+ } else {
var = ast_load_realtime("voicemail", "mailbox", mailbox, "context", context, SENTINEL);
+ }
if (var) {
apply_options_full(retval, var);
ast_variables_destroy(var);
@@ -2419,8 +2423,10 @@
return -1;
}
if ((*newmsgs = __messagecount(context, mailboxnc, vmu->imapfolder)) < 0) {
+ free_user(vmu);
return -1;
}
+ free_user(vmu);
}
if (oldmsgs) {
if ((*oldmsgs = __messagecount(context, mailboxnc, "Old")) < 0) {
@@ -2737,8 +2743,9 @@
vmu = ast_calloc(1, sizeof *vmu);
if (!vmu)
return NULL;
+
+ populate_defaults(vmu);
ast_set_flag(vmu, VM_ALLOCED);
- populate_defaults(vmu);
var = ast_load_realtime("voicemail", "imapuser", imapuser, NULL);
if (var) {
@@ -10858,8 +10865,8 @@
if (!(vmu = ast_calloc(1, sizeof(*vmu)))) {
return AST_TEST_NOT_RUN;
}
+ populate_defaults(vmu);
ast_set_flag(vmu, VM_ALLOCED);
- populate_defaults(vmu);
apply_options(vmu, options_string);
@@ -10987,7 +10994,7 @@
res = 1;
}
if (strcasecmp(vmu->imapfolder, "INBOX")) {
- ast_test_status_update(test, "Parse failure for imappasswd option\n");
+ ast_test_status_update(test, "Parse failure for imapfolder option\n");
res = 1;
}
if (strcasecmp(vmu->imapvmshareid, "6000")) {
More information about the asterisk-commits
mailing list