Fix possible race...
authorMark Spencer <markster@digium.com>
Sun, 14 Nov 2004 05:52:08 +0000 (05:52 +0000)
committerMark Spencer <markster@digium.com>
Sun, 14 Nov 2004 05:52:08 +0000 (05:52 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@4238 65c4cc65-6c06-0410-ace0-fbb531ad65f3

manager.c

index 7bfccaa..55f2ebe 100755 (executable)
--- a/manager.c
+++ b/manager.c
@@ -614,6 +614,7 @@ static int action_getvar(struct mansession *s, struct message *m)
         char *varname = astman_get_header(m, "Variable");
        char *id = astman_get_header(m,"ActionID");
        char *varval;
+       char *varval2=NULL;
 
        if (!strlen(name)) {
                astman_send_error(s, m, "No channel specified");
@@ -638,11 +639,14 @@ static int action_getvar(struct mansession *s, struct message *m)
        }
        
        varval=pbx_builtin_getvar_helper(c,varname);
-         
+       if (varval)
+               varval2 = ast_strdupa(varval);
+       if (!varval2)
+               varval2 = "";
        ast_mutex_unlock(&c->lock);
        ast_mutex_lock(&s->lock);
        ast_cli(s->fd, "Response: Success\r\n"
-               "%s: %s\r\n" ,varname,varval);
+               "%s: %s\r\n" ,varname,varval2);
        if (id && !ast_strlen_zero(id))
                ast_cli(s->fd, "ActionID: %s\r\n",id);
        ast_cli(s->fd, "\r\n");