diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-08-26 19:45:16 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-08-26 19:45:16 +0000 |
commit | d60ef591f32d5d690891dc0ea476d853ad265b45 (patch) | |
tree | fa90bdc618e9f11a4c305bbcb5ce66a9c7e0352b | |
parent | 033e4fd7b520e949011acf115044c9e02f80cf6f (diff) |
ensure that unload_dynamic_module won't continue dereferencing a module pointer after the module has been unloaded from memory
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@41196 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | main/loader.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/main/loader.c b/main/loader.c index 4ece4ae6b..30f5aa660 100644 --- a/main/loader.c +++ b/main/loader.c @@ -323,9 +323,14 @@ static struct ast_module *find_resource(const char *resource, int do_lock) #if LOADABLE_MODULES static void unload_dynamic_module(struct ast_module *mod) { - if (mod->lib) - while (!dlclose(mod->lib)); - /* WARNING: the structure pointed to by mod is now gone! */ + void *lib = mod->lib; + + /* WARNING: the structure pointed to by mod is going to + disappear when this operation succeeds, so we can't + dereference it */ + + if (lib) + while (!dlclose(lib)); } static struct ast_module *load_dynamic_module(const char *resource_in, unsigned int global_symbols_only) |