summaryrefslogtreecommitdiff
path: root/tests/test_gosub.c
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2015-06-08 11:09:57 -0400
committerCorey Farrell <git@cfware.com>2015-06-08 11:09:57 -0400
commit80621ce3c5da5062f7e3efb42d6e8fcdd9caa3f6 (patch)
tree830f2bf1823901045bccffe224a858ba70b7a9e8 /tests/test_gosub.c
parent8785d0ccbfa1959d1ba6be8769e9d5356f3fef32 (diff)
Fix unsafe uses of ast_context pointers.
Although ast_context_find, ast_context_find_or_create and ast_context_destroy perform locking of the contexts table, any context pointer can become invalid at any time that the contexts table is unlocked. This change adds locking around all complete operations involving these functions. Places where ast_context_find was followed by ast_context_destroy have been replaced with calls ast_context_destroy_by_name. ASTERISK-25094 #close Reported by: Corey Farrell Change-Id: I1866b6787730c9c4f3f836b6133ffe9c820734fa
Diffstat (limited to 'tests/test_gosub.c')
-rw-r--r--tests/test_gosub.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/test_gosub.c b/tests/test_gosub.c
index c4b071ee2..e0f618cd5 100644
--- a/tests/test_gosub.c
+++ b/tests/test_gosub.c
@@ -42,10 +42,10 @@ ASTERISK_REGISTER_FILE()
AST_TEST_DEFINE(test_gosub)
{
+#define CONTEXT_NAME "tests_test_gosub_virtual_context"
int res = AST_TEST_PASS, i;
struct ast_channel *chan;
struct ast_str *str;
- struct ast_context *con;
struct testplan {
const char *app;
const char *args;
@@ -119,14 +119,14 @@ AST_TEST_DEFINE(test_gosub)
}
/* Create our test dialplan */
- if (!(con = ast_context_find_or_create(NULL, NULL, "tests_test_gosub_virtual_context", "test_gosub"))) {
+ if (!ast_context_find_or_create(NULL, NULL, CONTEXT_NAME, "test_gosub")) {
ast_test_status_update(test, "Unable to create test dialplan context");
ast_free(str);
ast_channel_unref(chan);
return AST_TEST_FAIL;
}
- ast_add_extension2(con, 1, "s", 1, NULL, NULL, "NoOp", ast_strdup(""), ast_free_ptr, "test_gosub");
+ ast_add_extension(CONTEXT_NAME, 1, "s", 1, NULL, NULL, "NoOp", ast_strdup(""), ast_free_ptr, "test_gosub");
for (i = 0; i < ARRAY_LEN(testplan); i++) {
if (testplan[i].app == NULL) {
@@ -157,8 +157,8 @@ AST_TEST_DEFINE(test_gosub)
ast_free(str);
ast_channel_unref(chan);
- ast_context_remove_extension2(con, "s", 1, NULL, 0);
- ast_context_destroy(con, "test_gosub");
+ ast_context_remove_extension(CONTEXT_NAME, "s", 1, NULL);
+ ast_context_destroy(NULL, "test_gosub");
return res;
}