diff options
author | Corey Farrell <git@cfware.com> | 2015-05-14 01:06:53 -0400 |
---|---|---|
committer | Corey Farrell <git@cfware.com> | 2015-05-14 05:41:22 -0500 |
commit | 6b7282ca4037114ac19da5149dce958f837d1422 (patch) | |
tree | 79b13cc832daf6ba18855ecf68023b63f0950863 /tests | |
parent | 586da882bc62bd10a46d7da610b18b6c7c290e91 (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 'tests')
-rw-r--r-- | tests/test_message.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/tests/test_message.c b/tests/test_message.c index 5db0ed044..285905d8c 100644 --- a/tests/test_message.c +++ b/tests/test_message.c @@ -51,8 +51,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") /*! \brief The number of user events we should get in a dialplan test */ #define DEFAULT_EXPECTED_EVENTS 4 -static struct ast_context *test_message_context; - /*! \brief The current number of received user events */ static int received_user_events; @@ -822,9 +820,7 @@ static int unload_module(void) AST_TEST_UNREGISTER(test_message_has_destination_handler); AST_TEST_UNREGISTER(test_message_msg_send); - if (test_message_context) { - ast_context_destroy(test_message_context, AST_MODULE); - } + ast_context_destroy(NULL, AST_MODULE); ast_manager_unregister_hook(&user_event_hook); @@ -835,8 +831,7 @@ static int create_test_dialplan(void) { int res = 0; - test_message_context = ast_context_find_or_create(NULL, NULL, TEST_CONTEXT, AST_MODULE); - if (!test_message_context) { + if (!ast_context_find_or_create(NULL, NULL, TEST_CONTEXT, AST_MODULE)) { return -1; } |