From: Tilghman Lesher Date: Mon, 4 Aug 2008 16:56:19 +0000 (+0000) Subject: Memory leak on unload X-Git-Tag: 1.4.22-rc1~39 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b0e98705355acfe73bc6426c9d403319a804eccd;p=thirdparty%2Fasterisk.git Memory leak on unload (closes issue #13231) Reported by: eliel Patches: app_voicemail.leak.patch uploaded by eliel (license 64) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@135479 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 61bdfc45ab..09a6304450 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -7844,10 +7844,28 @@ static struct ast_cli_entry cli_voicemail[] = { voicemail_show_zones_help, NULL, &cli_show_voicemail_zones_deprecated }, }; -static int load_config(void) +static void free_vm_users(void) { struct ast_vm_user *cur; struct vm_zone *zcur; + + AST_LIST_LOCK(&users); + while ((cur = AST_LIST_REMOVE_HEAD(&users, list))) { + ast_set_flag(cur, VM_ALLOCED); + free_user(cur); + } + AST_LIST_UNLOCK(&users); + + AST_LIST_LOCK(&zones); + while ((zcur = AST_LIST_REMOVE_HEAD(&zones, list))) { + free_zone(zcur); + } + AST_LIST_UNLOCK(&zones); +} + +static int load_config(void) +{ + struct ast_vm_user *cur; struct ast_config *cfg, *ucfg; char *cat; struct ast_variable *var; @@ -7897,16 +7915,9 @@ static int load_config(void) cfg = ast_config_load(VOICEMAIL_CONFIG); - AST_LIST_LOCK(&users); - while ((cur = AST_LIST_REMOVE_HEAD(&users, list))) { - ast_set_flag(cur, VM_ALLOCED); - free_user(cur); - } + free_vm_users(); - AST_LIST_LOCK(&zones); - while ((zcur = AST_LIST_REMOVE_HEAD(&zones, list))) - free_zone(zcur); - AST_LIST_UNLOCK(&zones); + AST_LIST_LOCK(&users); memset(ext_pass_cmd, 0, sizeof(ext_pass_cmd));