From ccdfe67bf2f1c9ea00b522a4e59d7e245b7fb7df Mon Sep 17 00:00:00 2001 From: Walter Doekes Date: Tue, 6 Aug 2013 08:36:15 +0000 Subject: Check result of ast_var_assign() calls for memory allocation failure. We try to keep the system running even when all available memory is spent. Review: https://reviewboard.asterisk.org/r/2734/ ........ Merged revisions 396279 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 396287 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@396309 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- pbx/pbx_loopback.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'pbx/pbx_loopback.c') diff --git a/pbx/pbx_loopback.c b/pbx/pbx_loopback.c index 5f3561343..dc9e7c7ac 100644 --- a/pbx/pbx_loopback.c +++ b/pbx/pbx_loopback.c @@ -91,12 +91,15 @@ static char *loopback_subst(char *buf, int buflen, const char *exten, const char snprintf(tmp, sizeof(tmp), "%d", priority); AST_LIST_HEAD_INIT_NOLOCK(&headp); - newvariable = ast_var_assign("EXTEN", exten); - AST_LIST_INSERT_HEAD(&headp, newvariable, entries); - newvariable = ast_var_assign("CONTEXT", context); - AST_LIST_INSERT_HEAD(&headp, newvariable, entries); - newvariable = ast_var_assign("PRIORITY", tmp); - AST_LIST_INSERT_HEAD(&headp, newvariable, entries); + if ((newvariable = ast_var_assign("EXTEN", exten))) { + AST_LIST_INSERT_HEAD(&headp, newvariable, entries); + } + if ((newvariable = ast_var_assign("CONTEXT", context))) { + AST_LIST_INSERT_HEAD(&headp, newvariable, entries); + } + if ((newvariable = ast_var_assign("PRIORITY", tmp))) { + AST_LIST_INSERT_HEAD(&headp, newvariable, entries); + } /* Substitute variables */ pbx_substitute_variables_varshead(&headp, data, buf, buflen); /* free the list */ -- cgit v1.2.3