[asterisk-commits] mmichelson: trunk r187680 - /trunk/main/channel.c
    SVN commits to the Asterisk project 
    asterisk-commits at lists.digium.com
       
    Fri Apr 10 11:06:25 CDT 2009
    
    
  
Author: mmichelson
Date: Fri Apr 10 11:06:22 2009
New Revision: 187680
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=187680
Log:
Don't let ast_channel_alloc fail if explicitly passed NULL cid_name or cid_number.
This also fixes a small memory leak.
Modified:
    trunk/main/channel.c
Modified: trunk/main/channel.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/main/channel.c?view=diff&rev=187680&r1=187679&r2=187680
==============================================================================
--- trunk/main/channel.c (original)
+++ trunk/main/channel.c Fri Apr 10 11:06:22 2009
@@ -796,11 +796,22 @@
 		return NULL;
 	}
 
-	if (!(tmp->cid.cid_name = ast_strdup(cid_name)) || !(tmp->cid.cid_num = ast_strdup(cid_num))) {
-		ast_string_field_free_memory(tmp);
-		sched_context_destroy(tmp->sched);
-		ast_free(tmp);
-		return NULL;
+	if (cid_name) {
+		if (!(tmp->cid.cid_name = ast_strdup(cid_name))) {
+			ast_string_field_free_memory(tmp);
+			sched_context_destroy(tmp->sched);
+			ast_free(tmp);
+			return NULL;
+		}
+	}
+	if (cid_num) {
+		if (!(tmp->cid.cid_num = ast_strdup(cid_num))) {
+			ast_string_field_free_memory(tmp);
+			sched_context_destroy(tmp->sched);
+			ast_free(tmp->cid.cid_name);
+			ast_free(tmp);
+			return NULL;
+		}
 	}
 
 #ifdef HAVE_EPOLL
    
    
More information about the asterisk-commits
mailing list