Merged revisions 243486 via svnmerge from
authorMark Michelson <mmichelson@digium.com>
Wed, 27 Jan 2010 18:08:02 +0000 (18:08 +0000)
committerMark Michelson <mmichelson@digium.com>
Wed, 27 Jan 2010 18:08:02 +0000 (18:08 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r243486 | mmichelson | 2010-01-27 12:06:43 -0600 (Wed, 27 Jan 2010) | 3 lines

  Use a safe list traversal while checking for duplicate vars in pbx_builtin_setvar_helper.
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@243487 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/pbx.c

index c13feff..3b3b1cd 100644 (file)
@@ -9434,14 +9434,15 @@ int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const
                        nametail++;
        }
 
-       AST_LIST_TRAVERSE (headp, newvariable, entries) {
+       AST_LIST_TRAVERSE_SAFE_BEGIN(headp, newvariable, entries) {
                if (strcasecmp(ast_var_name(newvariable), nametail) == 0) {
                        /* there is already such a variable, delete it */
-                       AST_LIST_REMOVE(headp, newvariable, entries);
+                       AST_LIST_REMOVE_CURRENT(entries);
                        ast_var_delete(newvariable);
                        break;
                }
        }
+       AST_LIST_TRAVERSE_SAFE_END;
 
        if (value) {
                if (headp == &globals)