aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-06-17 19:59:31 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-06-17 19:59:31 +0000
commit976bbc3d6d05d09d1051ad6acd9063f313c66429 (patch)
treec0d6ad7581e771e8e8f296e9f706ac99954cda70 /main
parentdfe08b37d004a56a7048aa35097cd0c6415d40f8 (diff)
Change the datastore traversal in ast_do_masquerade to use a safe list traversal.
It is possible for datastore fixup functions to remove the datastore from the list and free it. In particular, the queue_transfer_fixup in app_queue does this. While I don't yet know of this causing any crashes, it certainly could. Found while discussing a separate issue with Brian Degenhardt. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@201450 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/channel.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/main/channel.c b/main/channel.c
index 0add3a824..98e9c3f37 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -3888,10 +3888,14 @@ int ast_do_masquerade(struct ast_channel *original)
/* Move data stores over */
if (AST_LIST_FIRST(&clone->datastores)) {
struct ast_datastore *ds;
- AST_LIST_TRAVERSE(&clone->datastores, ds, entry) {
+ /* We use a safe traversal here because some fixup routines actually
+ * remove the datastore from the list and free them.
+ */
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&clone->datastores, ds, entry) {
if (ds->info->chan_fixup)
ds->info->chan_fixup(ds->data, clone, original);
}
+ AST_LIST_TRAVERSE_SAFE_END;
AST_LIST_APPEND_LIST(&original->datastores, &clone->datastores, entry);
}