From 9f0cf49bca526618ed261bd26f612a6e126cfeae Mon Sep 17 00:00:00 2001
From: Russell Bryant <russell@russellbryant.com>
Date: Wed, 28 Sep 2005 19:42:36 +0000
Subject: [PATCH] make sure to LOCAL_USER_REMOVE in all cases where the
 application can exit (issue #5307)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6678 65c4cc65-6c06-0410-ace0-fbb531ad65f3
---
 apps/app_chanisavail.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/apps/app_chanisavail.c b/apps/app_chanisavail.c
index 791851f08b..4e5e524495 100755
--- a/apps/app_chanisavail.c
+++ b/apps/app_chanisavail.c
@@ -101,6 +101,7 @@ static int chanavail_exec(struct ast_channel *chan, void *data)
 			number = strchr(tech, '/');
 			if (!number) {
 				ast_log(LOG_WARNING, "ChanIsAvail argument takes format ([technology]/[device])\n");
+				LOCAL_USER_REMOVE(u);
 				return -1;
 			}
 			*number = '\0';
@@ -135,8 +136,10 @@ static int chanavail_exec(struct ast_channel *chan, void *data)
 	if (res < 1) {
 		pbx_builtin_setvar_helper(chan, "AVAILCHAN", "");
 		pbx_builtin_setvar_helper(chan, "AVAILORIGCHAN", "");
-		if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101))
+		if (ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101)) {
+			LOCAL_USER_REMOVE(u);
 			return -1;
+		}
 	}
 
 	LOCAL_USER_REMOVE(u);
-- 
GitLab