[asterisk-commits] mjordan: branch 12 r426174 - /branches/12/res/res_phoneprov.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Oct 26 21:27:06 CDT 2014


Author: mjordan
Date: Sun Oct 26 21:27:03 2014
New Revision: 426174

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=426174
Log:
res/res_phoneprov: Fix crash on shutdown caused by container cleanup

In res_phoneprov, unloading the module first destroys the http_routes
container, followed by the users. However, users may have a route in
the http_routes container; the validity of this container is not checked
in the users destructor. Hence, we hit an assert as the container has already
been set to NULL.

This patch does two things:
(1) It adds a sanity check in the user destructor (because why not)
(2) It switches the order of destruction, so that users are disposed of prior
    to the HTTP routes they may hold a reference to.

Note that this crash was caught by the Test Suite (go go testing!)

Modified:
    branches/12/res/res_phoneprov.c

Modified: branches/12/res/res_phoneprov.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_phoneprov.c?view=diff&rev=426174&r1=426173&r2=426174
==============================================================================
--- branches/12/res/res_phoneprov.c (original)
+++ branches/12/res/res_phoneprov.c Sun Oct 26 21:27:03 2014
@@ -758,7 +758,9 @@
 		user->profile = unref_profile(user->profile);
 	}
 
-	ao2_callback(http_routes, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, routes_delete_cb, (void *)user->macaddress);
+	if (http_routes) {
+		ao2_callback(http_routes, OBJ_UNLINK | OBJ_NODATA | OBJ_MULTIPLE, routes_delete_cb, (void *)user->macaddress);
+	}
 
 	ast_string_field_free_memory(user);
 }
@@ -1382,9 +1384,9 @@
 	ao2_cleanup(profiles);
 	profiles = NULL;
 	delete_routes();
+	delete_users();
 	ao2_cleanup(http_routes);
 	http_routes = NULL;
-	delete_users();
 	ao2_cleanup(users);
 	users = NULL;
 	delete_providers();




More information about the asterisk-commits mailing list