]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Move a NULL check to a place that makes more sense.
authorMark Michelson <mmichelson@digium.com>
Tue, 12 Nov 2013 19:08:14 +0000 (19:08 +0000)
committerMark Michelson <mmichelson@digium.com>
Tue, 12 Nov 2013 19:08:14 +0000 (19:08 +0000)
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

main/channel.c

index a44279d2226532ceb4489e365dbb046706c63275..0b87b8039c119d193b2c96eaefbcbeeac32f7d78 100644 (file)
@@ -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;