From 9a3872cc77bdf401031b8fb53973be835effc890 Mon Sep 17 00:00:00 2001 From: russell Date: Sat, 27 Oct 2007 01:15:02 +0000 Subject: 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 --- funcs/func_lock.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'funcs/func_lock.c') 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; } -- cgit v1.2.3