summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2012-11-29 23:01:16 +0000
committerRichard Mudgett <rmudgett@digium.com>2012-11-29 23:01:16 +0000
commit9a8ce96aff2206125e627a096d44aecbddca0a3d (patch)
treef627f0a54c898f6a5096ec69841124766f21ebde /channels
parent53e97bc9ee249ff31e81a16857128f11d6ef378f (diff)
chan_local: Fix local_pvt ref leak in local_devicestate().
Regression introduced by ASTERISK-20390 fix. (closes issue ASTERISK-20769) Reported by: rmudgett Tested by: rmudgett ........ Merged revisions 376868 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 376869 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 376870 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@376871 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_local.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c
index 4e0316670..da86e1473 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -311,15 +311,20 @@ static int local_devicestate(const char *data)
res = AST_DEVICE_NOT_INUSE;
it = ao2_iterator_init(locals, 0);
- while ((lp = ao2_iterator_next(&it)) && (res == AST_DEVICE_NOT_INUSE)) {
- if (!strcmp(exten, lp->exten) && !strcmp(context, lp->context) && lp->owner) {
- ao2_lock(lp);
- if (ast_test_flag(lp, LOCAL_LAUNCHED_PBX)) {
- res = AST_DEVICE_INUSE;
- }
- ao2_unlock(lp);
+ for (; (lp = ao2_iterator_next(&it)); ao2_ref(lp, -1)) {
+ int is_inuse;
+
+ ao2_lock(lp);
+ is_inuse = !strcmp(exten, lp->exten)
+ && !strcmp(context, lp->context)
+ && lp->owner
+ && ast_test_flag(lp, LOCAL_LAUNCHED_PBX);
+ ao2_unlock(lp);
+ if (is_inuse) {
+ res = AST_DEVICE_INUSE;
+ ao2_ref(lp, -1);
+ break;
}
- ao2_ref(lp, -1);
}
ao2_iterator_destroy(&it);