summaryrefslogtreecommitdiff
path: root/main/loader.c
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2006-08-26 19:45:16 +0000
committerKevin P. Fleming <kpfleming@digium.com>2006-08-26 19:45:16 +0000
commita757ca294799f7e014b3dd7083943ac7e1630614 (patch)
treefa90bdc618e9f11a4c305bbcb5ce66a9c7e0352b /main/loader.c
parent3a83fbed5b81816a813782c083a464abf9348bcc (diff)
ensure that unload_dynamic_module won't continue dereferencing a module pointer after the module has been unloaded from memory
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@41196 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/loader.c')
-rw-r--r--main/loader.c11
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)