don't crash on setvar (issue #5760)
authorRussell Bryant <russell@russellbryant.com>
Tue, 15 Nov 2005 18:35:30 +0000 (18:35 +0000)
committerRussell Bryant <russell@russellbryant.com>
Tue, 15 Nov 2005 18:35:30 +0000 (18:35 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7099 65c4cc65-6c06-0410-ace0-fbb531ad65f3

ChangeLog
manager.c

index 8d7f0a9..99a5ca9 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2005-11-15  Russell Bryant <russell@digium.com>
 
 2005-11-15  Russell Bryant <russell@digium.com>
 
+       * manager.c: Don't crash on a SetVar action if the channel name is not set, or variable's value is not set (issue #5760)
+
        * doc/README.variables: Add application exit status variables
 
 2005-11-14  Josh Roberson <josh@asteirasgi.com>
        * doc/README.variables: Add application exit status variables
 
 2005-11-14  Josh Roberson <josh@asteirasgi.com>
index 629cad2..ea813d6 100755 (executable)
--- a/manager.c
+++ b/manager.c
@@ -689,6 +689,11 @@ static int action_setvar(struct mansession *s, struct message *m)
                astman_send_error(s, m, "No variable specified");
                return 0;
        }
                astman_send_error(s, m, "No variable specified");
                return 0;
        }
+       
+       if (ast_strlen_zero(varval)) {
+               astman_send_error(s, m, "No value specified");
+               return 0;
+       }
 
        if (!ast_strlen_zero(name)) {
                c = ast_get_channel_by_name_locked(name);
 
        if (!ast_strlen_zero(name)) {
                c = ast_get_channel_by_name_locked(name);
@@ -698,10 +703,12 @@ static int action_setvar(struct mansession *s, struct message *m)
                }
        }
        
                }
        }
        
-       pbx_builtin_setvar_helper(c,varname,varval);
+       pbx_builtin_setvar_helper(c, varname, varval);
          
          
-       ast_mutex_unlock(&c->lock);
-       astman_send_ack(s, m, "Variable Set");
+       if (c)
+               ast_mutex_unlock(&c->lock);
+
+       astman_send_ack(s, m, "Variable Set");  
 
        return 0;
 }
 
        return 0;
 }