diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-10-27 01:15:02 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-10-27 01:15:02 +0000 |
commit | 9a3872cc77bdf401031b8fb53973be835effc890 (patch) | |
tree | 33c24cab681846805633977e374f1eb6823748d0 /funcs/func_lock.c | |
parent | 39afbccd81f48f470089296ce51c132b81b73acb (diff) |
Make sure a channel exists before attempting to start or stop channel
autoservice in func_lock and func_shell.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@87233 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs/func_lock.c')
-rw-r--r-- | funcs/func_lock.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/funcs/func_lock.c b/funcs/func_lock.c index b8c685340..9985f26c5 100644 --- a/funcs/func_lock.c +++ b/funcs/func_lock.c @@ -256,19 +256,27 @@ static int unlock_read(struct ast_channel *chan, const char *cmd, char *data, ch } static int lock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) -{ - ast_autoservice_start(chan); +{ + if (chan) + ast_autoservice_start(chan); + ast_copy_string(buf, get_lock(chan, data, 0) ? "0" : "1", len); - ast_autoservice_stop(chan); + + if (chan) + ast_autoservice_stop(chan); return 0; } static int trylock_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { - ast_autoservice_start(chan); + if (chan) + ast_autoservice_start(chan); + ast_copy_string(buf, get_lock(chan, data, 1) ? "0" : "1", len); - ast_autoservice_stop(chan); + + if (chan) + ast_autoservice_stop(chan); return 0; } |