cleancleanup, prevent null deref.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@6719 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-12-13 00:19:53 +00:00
parent ba447633e8
commit 6452b66bf7
1 changed files with 9 additions and 11 deletions

View File

@ -150,7 +150,7 @@ static struct ast_iana AST_IANA[] = { {AST_FORMAT_G723_1, 4, "g723.1"},
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 @@ static switch_status_t iax_set_codec(private_t * tech_pvt, struct iax_session *i
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 @@ static switch_status_t iax_set_codec(private_t * tech_pvt, struct iax_session *i
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;
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);
}
} else if (((num_codecs = switch_loadable_module_get_codecs(codecs, SWITCH_MAX_CODECS))) <= 0) {
if (num_codecs <= 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO codecs?\n");
return SWITCH_STATUS_GENERR;
}
@ -246,6 +245,8 @@ static switch_status_t iax_set_codec(private_t * tech_pvt, struct iax_session *i
}
}
switch_assert(codecs[0]);
if (io == IAX_SET) {
mixed_cap = (local_cap & *cababilities);
} else {
@ -1104,9 +1105,6 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
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);