[asterisk-commits] russell: branch 1.2 r67715 -
	/branches/1.2/channel.c
    asterisk-commits at lists.digium.com 
    asterisk-commits at lists.digium.com
       
    Wed Jun  6 09:40:51 MST 2007
    
    
  
Author: russell
Date: Wed Jun  6 11:40:51 2007
New Revision: 67715
URL: http://svn.digium.com/view/asterisk?view=rev&rev=67715
Log:
We have some bug reports showing crashes due to a double free of a channel.
Add a sanity check to ast_channel_free() to make sure we don't go on trying
to free a channel that wasn't found in the channel list.
(issue #8850, and others...)
Modified:
    branches/1.2/channel.c
Modified: branches/1.2/channel.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channel.c?view=diff&rev=67715&r1=67714&r2=67715
==============================================================================
--- branches/1.2/channel.c (original)
+++ branches/1.2/channel.c Wed Jun  6 11:40:51 2007
@@ -897,14 +897,16 @@
 		last = cur;
 		cur = cur->next;
 	}
-	if (!cur)
-		ast_log(LOG_WARNING, "Unable to find channel in list\n");
-	else {
-		/* Lock and unlock the channel just to be sure nobody
-		   has it locked still */
-		ast_mutex_lock(&cur->lock);
-		ast_mutex_unlock(&cur->lock);
-	}
+	if (!cur) {
+		ast_mutex_unlock(&chlock);
+		ast_log(LOG_ERROR, "Unable to find channel in list to free. Assuming it has already been done.\n");
+		return;
+	}
+
+	/* Lock and unlock the channel just to be sure nobody
+	   has it locked still */
+	ast_mutex_lock(&cur->lock);
+	ast_mutex_unlock(&cur->lock);
 	if (chan->tech_pvt) {
 		ast_log(LOG_WARNING, "Channel '%s' may not have been hung up properly\n", chan->name);
 		free(chan->tech_pvt);
    
    
More information about the asterisk-commits
mailing list