[Freeswitch-trunk] [commit] r6719 - freeswitch/trunk/src/mod/endpoints/mod_iax

Freeswitch SVN mikej at freeswitch.org
Wed Dec 12 19:19:54 EST 2007


Author: mikej
Date: Wed Dec 12 19:19:53 2007
New Revision: 6719

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c

Log:
cleancleanup, prevent null deref.


Modified: freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_iax/mod_iax.c	Wed Dec 12 19:19:53 2007
@@ -150,7 +150,7 @@
 static char *ast2str(int ast)
 {
 	int x;
-	for (x = 0; x < 32; x++) {
+	for (x = 0; x < 19; x++) {
 		if ((1 << x) == ast) {
 			return AST_IANA[x].name;
 		}
@@ -216,8 +216,6 @@
 									 unsigned int *format, unsigned int *cababilities, unsigned short *samprate, iax_io_t io)
 {
 	char *dname = NULL;
-	//int rate = 8000;
-	//int codec_ms = 20;
 	switch_channel_t *channel;
 	const switch_codec_implementation_t *codecs[SWITCH_MAX_CODECS];
 	int num_codecs = 0;
@@ -226,11 +224,12 @@
 	uint32_t interval = 0;
 
 	if (globals.codec_string) {
-		if ((num_codecs = switch_loadable_module_get_codecs_sorted(codecs, SWITCH_MAX_CODECS, globals.codec_order, globals.codec_order_last)) <= 0) {
-			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
-			return SWITCH_STATUS_GENERR;
-		}
-	} else if (((num_codecs = switch_loadable_module_get_codecs(codecs, SWITCH_MAX_CODECS))) <= 0) {
+		num_codecs = switch_loadable_module_get_codecs_sorted(codecs, SWITCH_MAX_CODECS, globals.codec_order, globals.codec_order_last);
+	} else {
+		num_codecs = switch_loadable_module_get_codecs(codecs, SWITCH_MAX_CODECS);
+	}
+
+	if (num_codecs <= 0) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
 		return SWITCH_STATUS_GENERR;
 	}
@@ -246,6 +245,8 @@
 		}
 	}
 
+	switch_assert(codecs[0]);
+
 	if (io == IAX_SET) {
 		mixed_cap = (local_cap & *cababilities);
 	} else {
@@ -1104,9 +1105,6 @@
 
 					switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Inbound Channel %s!\n", iaxevent->ies.calling_name);
 					if ((session = switch_core_session_request(iax_endpoint_interface, NULL)) != 0) {
-						private_t *tech_pvt;
-						switch_channel_t *channel;
-
 						switch_core_session_add_stream(session, NULL);
 						if ((tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t))) != 0) {
 							channel = switch_core_session_get_channel(session);



More information about the Freeswitch-trunk mailing list