[svn-commits] rmudgett: branch 1.8 r376868 - /branches/1.8/channels/chan_local.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Nov 29 16:55:55 CST 2012


Author: rmudgett
Date: Thu Nov 29 16:55:51 2012
New Revision: 376868

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=376868
Log:
chan_local: Fix local_pvt ref leak in local_devicestate().

Regression introduced by ASTERISK-20390 fix.

Modified:
    branches/1.8/channels/chan_local.c

Modified: branches/1.8/channels/chan_local.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_local.c?view=diff&rev=376868&r1=376867&r2=376868
==============================================================================
--- branches/1.8/channels/chan_local.c (original)
+++ branches/1.8/channels/chan_local.c Thu Nov 29 16:55:51 2012
@@ -308,15 +308,20 @@
 	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);
-		}
-		ao2_ref(lp, -1);
+	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_iterator_destroy(&it);
 




More information about the svn-commits mailing list