From: Mark Michelson Date: Fri, 25 Apr 2008 16:25:17 +0000 (+0000) Subject: Fix a memory leak and protect against potential dereferences of a NULL X-Git-Tag: 1.6.2.0-beta1~2383 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2b2571d0111ec1619ad30e480a387be41b5b70c8;p=thirdparty%2Fasterisk.git Fix a memory leak and protect against potential dereferences of a NULL pointer. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114651 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index bbb2af686d..04b0ca4ce4 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -4561,11 +4561,11 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu, strncat(textfile, ".txt", sizeof(textfile) - strlen(textfile) - 1); strncat(backup, "-bak", sizeof(backup) - strlen(backup) - 1); - msg_cfg = ast_config_load(textfile, config_flags); - - *duration = 0; - if ((duration_str = ast_variable_retrieve(msg_cfg, "message", "duration"))) + if ((msg_cfg = ast_config_load(textfile, config_flags)) && (duration_str = ast_variable_retrieve(msg_cfg, "message", "duration"))) { *duration = atoi(duration_str); + } else { + *duration = 0; + } while ((cmd >= 0) && (cmd != 't') && (cmd != '*')) { if (cmd) @@ -4576,7 +4576,7 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu, prepend_duration = 0; /* if we can't read the message metadata, stop now */ - if (!(msg_cfg = ast_config_load(textfile, config_flags))) { + if (!msg_cfg) { cmd = 0; break; } @@ -4631,7 +4631,8 @@ static int vm_forwardoptions(struct ast_channel *chan, struct ast_vm_user *vmu, } } - ast_config_destroy(msg_cfg); + if (msg_cfg) + ast_config_destroy(msg_cfg); if (already_recorded) ast_filedelete(backup, NULL); if (prepend_duration)