From 8c7948fd44c5b9f44c1a58581b631cdeb81e4c02 Mon Sep 17 00:00:00 2001 From: Mark Michelson Date: Fri, 21 Dec 2007 16:49:35 +0000 Subject: [PATCH] Since we are freeing list elements within a list traversal, we need to use the safe traversal and remove the item from the list before freeing it. (closes issue 11612, reported by dtyoo) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@94468 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/dial.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main/dial.c b/main/dial.c index 32004c0550..02bf03e22e 100644 --- a/main/dial.c +++ b/main/dial.c @@ -681,7 +681,7 @@ int ast_dial_destroy(struct ast_dial *dial) return -1; /* Hangup and deallocate all the dialed channels */ - AST_LIST_TRAVERSE(&dial->channels, channel, list) { + AST_LIST_TRAVERSE_SAFE_BEGIN(&dial->channels, channel, list) { /* Disable any enabled options */ for (i = 0; i < AST_DIAL_OPTION_MAX; i++) { if (!channel->options[i]) @@ -696,8 +696,10 @@ int ast_dial_destroy(struct ast_dial *dial) channel->owner = NULL; } /* Free structure */ + AST_LIST_REMOVE_CURRENT(&dial->channels, list); free(channel); } + AST_LIST_TRAVERSE_SAFE_END; /* Disable any enabled options globally */ for (i = 0; i < AST_DIAL_OPTION_MAX; i++) {