summaryrefslogtreecommitdiff
path: root/funcs
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2015-05-14 01:06:53 -0400
committerCorey Farrell <git@cfware.com>2015-05-14 05:41:30 -0500
commit0a46d43b9c36e1ad847455fc6577f1573e0cb216 (patch)
tree5cc6f54c531f4e08f7f0d261c509b12d1df8b273 /funcs
parent2bbfcfc647dc69089236cde0003ba88c3161d1ec (diff)
Fix potential crash after unload of func_periodic_hook or test_message.
These modules save a pointer to the context they create on load, and use that pointer to destroy the context at unload. It is not safe to save this pointer, it is replaced during load of pbx_config, pbx_lua or pbx_ael. This change causes the modules to pass NULL to ast_context_destroy, a safer way to perform the unregistration since it does not use a pointer that could become invalid. ASTERISK-25085 #close Reported by: Corey Farrell Change-Id: I6a00ec8e38046058f97dc703e1adcde9bf517835
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_periodic_hook.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/funcs/func_periodic_hook.c b/funcs/func_periodic_hook.c
index 6ddab5600..bb0ee0db7 100644
--- a/funcs/func_periodic_hook.c
+++ b/funcs/func_periodic_hook.c
@@ -446,13 +446,9 @@ static struct ast_custom_function hook_function = {
.write = hook_write,
};
-static struct ast_context *func_periodic_hook_context;
-
static int unload_module(void)
{
- if (func_periodic_hook_context) {
- ast_context_destroy(func_periodic_hook_context, AST_MODULE);
- }
+ ast_context_destroy(NULL, AST_MODULE);
return ast_custom_function_unregister(&hook_function);
}
@@ -461,9 +457,7 @@ static int load_module(void)
{
int res;
- func_periodic_hook_context = ast_context_find_or_create(NULL, NULL,
- context_name, AST_MODULE);
- if (!func_periodic_hook_context) {
+ if (!ast_context_find_or_create(NULL, NULL, context_name, AST_MODULE)) {
ast_log(LOG_ERROR, "Failed to create %s dialplan context.\n", context_name);
return AST_MODULE_LOAD_DECLINE;
}