[asterisk-commits] jpeeler: branch jpeeler/issue18165 r293886 - /team/jpeeler/issue18165/main/pbx.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Nov 3 17:49:06 CDT 2010


Author: jpeeler
Date: Wed Nov  3 17:49:02 2010
New Revision: 293886

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=293886
Log:
that should fix accessing an extension for a hint that was freed

Modified:
    team/jpeeler/issue18165/main/pbx.c

Modified: team/jpeeler/issue18165/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/issue18165/main/pbx.c?view=diff&rev=293886&r1=293885&r2=293886
==============================================================================
--- team/jpeeler/issue18165/main/pbx.c (original)
+++ team/jpeeler/issue18165/main/pbx.c Wed Nov  3 17:49:02 2010
@@ -2051,6 +2051,16 @@
 
 		ast_rdlock_contexts();
 		ao2_lock(hints);
+		ao2_lock(hint);
+
+		if (hint->exten == NULL) {
+			/* the extension has been destroyed */
+			ao2_unlock(hint);
+			ao2_unlock(hints);
+			ast_unlock_contexts();
+			continue;
+		}
+
 		/* For general callbacks */
 		for (cblist = statecbs; cblist; cblist = cblist->next) {
 			cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data);
@@ -2066,7 +2076,6 @@
 
 		hint->laststate = state;	/* record we saw the change */
 		ao2_unlock(hint);
-
 		ao2_unlock(hints);
 		ast_unlock_contexts();
 	}
@@ -2285,6 +2294,7 @@
 	if (!hint) {
 		return -1;
 	}
+	ao2_lock(hint);
 
 	cbprev = NULL;
 	cblist = hint->callbacks;
@@ -2295,7 +2305,9 @@
 		ast_free(cbprev);
 	}
 	hint->callbacks = NULL;
+	hint->exten = NULL;
 	ao2_unlink(hints, hint);
+	ao2_unlock(hint);
 	ao2_ref(hint, -1);
 
 	return 0;




More information about the asterisk-commits mailing list