From 02b29263514248d927c397a4ad8b8f5e8da97997 Mon Sep 17 00:00:00 2001 From: Stefan Knoblich Date: Sun, 6 Mar 2011 19:34:03 +0100 Subject: [PATCH] [FreeTDM] Fix segfault in ftdm_analog_configure_span() on startup. Using ftdm_log_chan() in ftdm_analog_configure_span() is a bad idea, since the span won't have any channels assigned. This bug powered by declaring all variables at the top of the function, even if they are used in an if branch at the end. A C99'ish: if (callwaiting) { for (unsigned int i = 1; i <= span->span->chan_count; i++) { /* ... */ } } would have alerted the developer adding the log statement. But since we can't have nice things (thanks MSVC for not supporting C99!) Signed-off-by: Stefan Knoblich --- libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c index d25d38f3d7..21008e6c96 100644 --- a/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c +++ b/libs/freetdm/src/ftmod/ftmod_analog/ftmod_analog.c @@ -226,7 +226,7 @@ static FIO_SIG_CONFIGURE_FUNCTION(ftdm_analog_configure_span) if (wait_dialtone_timeout < 0) { wait_dialtone_timeout = 0; } - ftdm_log_chan(span->channels[i], FTDM_LOG_DEBUG, "Wait dial tone ms = %d\n", wait_dialtone_timeout); + ftdm_log(FTDM_LOG_DEBUG, "Wait dial tone ms = %d\n", wait_dialtone_timeout); } else if (!strcasecmp(var, "enable_callerid")) { if (!(val = va_arg(ap, char *))) { break;