diff --git a/main/channel.c b/main/channel.c index 1ba4f1a24a..83b6590fcc 100644 --- a/main/channel.c +++ b/main/channel.c @@ -1844,9 +1844,11 @@ static void ast_channel_destructor(void *obj) ast_cel_check_retire_linkedid(chan); /* Get rid of each of the data stores on the channel */ + ast_channel_lock(chan); while ((datastore = AST_LIST_REMOVE_HEAD(&chan->datastores, entry))) /* Free the data store */ ast_datastore_free(datastore); + ast_channel_unlock(chan); /* Lock and unlock the channel just to be sure nobody has it locked still due to a reference that was stored in a datastore. (i.e. app_chanspy) */