[asterisk-commits] mjordan: branch 10 r372288 - in /branches/10: ./ apps/app_voicemail.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Sep 5 08:42:58 CDT 2012
Author: mjordan
Date: Wed Sep 5 08:42:54 2012
New Revision: 372288
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=372288
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
........
Merged revisions 372268 from http://svn.asterisk.org/svn/asterisk/branches/1.8
Modified:
branches/10/ (props changed)
branches/10/apps/app_voicemail.c
Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.
Modified: branches/10/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/apps/app_voicemail.c?view=diff&rev=372288&r1=372287&r2=372288
==============================================================================
--- branches/10/apps/app_voicemail.c (original)
+++ branches/10/apps/app_voicemail.c Wed Sep 5 08:42:54 2012
@@ -1408,17 +1408,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);
@@ -2418,8 +2422,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) {
@@ -2733,8 +2739,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) {
@@ -10849,8 +10856,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);
@@ -10978,7 +10985,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