summaryrefslogtreecommitdiff
path: root/res/res_phoneprov.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2014-10-27 02:27:23 +0000
committerMatthew Jordan <mjordan@digium.com>2014-10-27 02:27:23 +0000
commitf3fbcc550ed1a9bd1aa59a9970a6f0103a73627f (patch)
tree469126b7c8b5cad7a1be9ac22131743a41d7fe8c /res/res_phoneprov.c
parent775640f658ca0f98ecd2e7b14a20a67a8072c7cc (diff)
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!) ........ Merged revisions 426174 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@426176 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_phoneprov.c')
-rw-r--r--res/res_phoneprov.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/res/res_phoneprov.c b/res/res_phoneprov.c
index 7aa157d01..ce008d20f 100644
--- a/res/res_phoneprov.c
+++ b/res/res_phoneprov.c
@@ -758,7 +758,9 @@ static void user_destructor(void *obj)
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 @@ static int unload_module(void)
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();