[asterisk-commits] trunk r23854 - /trunk/channels/chan_misdn.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Apr 30 20:58:14 MST 2006


Author: tilghman
Date: Sun Apr 30 22:58:13 2006
New Revision: 23854

URL: http://svn.digium.com/view/asterisk?rev=23854&view=rev
Log:
Don't return stack pointers from functions (especially since the code will attempt to free() them later)

Modified:
    trunk/channels/chan_misdn.c

Modified: trunk/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_misdn.c?rev=23854&r1=23853&r2=23854&view=diff
==============================================================================
--- trunk/channels/chan_misdn.c (original)
+++ trunk/channels/chan_misdn.c Sun Apr 30 22:58:13 2006
@@ -930,7 +930,7 @@
 		c = ast_channel_walk_locked(c);
 	}
 	if (c) {
-		ret = ast_strdupa(c->name);
+		ret = strdup(c->name);
 		ast_mutex_unlock(&c->lock);
 	} else
 		ret = NULL;
@@ -949,12 +949,12 @@
 
 	switch (pos) {
 	case 4: if (*word == 'p')
-				return ast_strdupa("port");
+				return strdup("port");
 			else if (*word == 'o')
-				return ast_strdupa("only");
+				return strdup("only");
 			break;
 	case 6: if (*word == 'o')
-				return ast_strdupa("only");
+				return strdup("only");
 			break;
 	}
 	return NULL;
@@ -1512,8 +1512,11 @@
 			ast_set_callerid(ast, bc->oad, NULL, bc->oad);
 		}
 		
-		if ( !ast_strlen_zero(bc->rad) ) 
-			ast->cid.cid_rdnis=ast_strdupa(bc->rad);
+		if ( !ast_strlen_zero(bc->rad) ) {
+			if (ast->cid.cid_rdnis)
+				free(ast->cid.cid_rdnis);
+			ast->cid.cid_rdnis = strdup(bc->rad);
+		}
 	}
 	return 0;
 }



More information about the asterisk-commits mailing list