summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2009-06-17 20:04:12 +0000
committerMark Michelson <mmichelson@digium.com>2009-06-17 20:04:12 +0000
commitd8cc968adc2f6281076563e045577af2d8edd610 (patch)
treeb263df735cc36263e6dd4f789c9736f3fadc9d9b /main
parent82e4b252303f7922e9a00dd92f677a2ecc241add (diff)
Merged revisions 201450 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r201450 | mmichelson | 2009-06-17 14:59:31 -0500 (Wed, 17 Jun 2009) | 9 lines 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: https://origsvn.digium.com/svn/asterisk/trunk@201458 65c4cc65-6c06-0410-ace0-fbb531ad65f3
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 5f4676f6b..bf35791fd 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -4835,10 +4835,14 @@ int ast_do_masquerade(struct ast_channel *original)
/* Move data stores over */
if (AST_LIST_FIRST(&clonechan->datastores)) {
struct ast_datastore *ds;
- AST_LIST_TRAVERSE(&clonechan->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(&clonechan->datastores, ds, entry) {
if (ds->info->chan_fixup)
ds->info->chan_fixup(ds->data, clonechan, original);
}
+ AST_LIST_TRAVERSE_SAFE_END;
AST_LIST_APPEND_LIST(&original->datastores, &clonechan->datastores, entry);
}