From: Mark Michelson Date: Tue, 12 Nov 2013 19:08:14 +0000 (+0000) Subject: Move a NULL check to a place that makes more sense. X-Git-Tag: 13.0.0-beta1~841 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0bc3f6b4cbb988412a325b1de854c27d7db1cb6;p=thirdparty%2Fasterisk.git Move a NULL check to a place that makes more sense. Two variables were being checked for NULLity immediately after being declared NULL. I moved the NULL check until after the variables are allocated. This allows for the "channelvars" option in manager.conf to work as intended again. ........ Merged revisions 402767 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@402768 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/channel.c b/main/channel.c index a44279d222..0b87b8039c 100644 --- a/main/channel.c +++ b/main/channel.c @@ -7596,10 +7596,6 @@ struct varshead *ast_channel_get_manager_vars(struct ast_channel *chan) RAII_VAR(struct ast_str *, tmp, NULL, ast_free); struct manager_channel_variable *mcv; - if (!ret || !tmp) { - return NULL; - } - AST_RWLIST_RDLOCK(&channelvars); if (AST_LIST_EMPTY(&channelvars)) { @@ -7609,6 +7605,10 @@ struct varshead *ast_channel_get_manager_vars(struct ast_channel *chan) ret = ao2_alloc(sizeof(*ret), varshead_dtor); tmp = ast_str_create(16); + if (!ret || !tmp) { + return NULL; + } + AST_LIST_TRAVERSE(&channelvars, mcv, entry) { const char *val = NULL; struct ast_var_t *var;