]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Change the datastore traversal in ast_do_masquerade to use a safe list traversal.
authorMark Michelson <mmichelson@digium.com>
Wed, 17 Jun 2009 19:59:31 +0000 (19:59 +0000)
committerMark Michelson <mmichelson@digium.com>
Wed, 17 Jun 2009 19:59:31 +0000 (19:59 +0000)
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/branches/1.4@201450 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/channel.c

index 0add3a82470b1c1422ec8a1108d9bd5d3d9d78bd..98e9c3f37fd2135289577f7230d08001796a1ee8 100644 (file)
@@ -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);
        }