diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-30 19:21:04 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-04-30 19:21:04 +0000 |
commit | 712c72b0df2fb7badefffb68c319f4a105ae9c71 (patch) | |
tree | 89d592fc9e276ed41a21062589ea44fedcf6d0d2 /apps/app_chanspy.c | |
parent | 829d44846c2cbb8f568e5368c8e033daba211ae0 (diff) |
Lock around variables retrieved, and copy the values, if they stay persistent,
since another thread could remove them.
(closes issue #12541)
Reported by: snuffy
Patches:
bug_12156_apps.diff uploaded by snuffy (license 35)
Several additional changes by me
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@114904 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_chanspy.c')
-rw-r--r-- | apps/app_chanspy.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c index d77fa4bbc..82c7afcef 100644 --- a/apps/app_chanspy.c +++ b/apps/app_chanspy.c @@ -596,12 +596,15 @@ static int common_exec(struct ast_channel *chan, const struct ast_flags *flags, if (ast_test_flag(flags, OPTION_EXIT)) { const char *c; - if ((c = pbx_builtin_getvar_helper(chan, "SPY_EXIT_CONTEXT"))) + ast_channel_lock(chan); + if ((c = pbx_builtin_getvar_helper(chan, "SPY_EXIT_CONTEXT"))) { ast_copy_string(exitcontext, c, sizeof(exitcontext)); - else if (!ast_strlen_zero(chan->macrocontext)) + } else if (!ast_strlen_zero(chan->macrocontext)) { ast_copy_string(exitcontext, chan->macrocontext, sizeof(exitcontext)); - else + } else { ast_copy_string(exitcontext, chan->context, sizeof(exitcontext)); + } + ast_channel_unlock(chan); } ast_mutex_init(&chanspy_ds.lock); |