From c6a8784e95d41da9584d41f9f4749b84194c89ab Mon Sep 17 00:00:00 2001 From: Luigi Rizzo Date: Wed, 19 Apr 2006 16:19:52 +0000 Subject: localize one more variable; use ast_strdup as it can handle the NULL argument well. mark a dubious piece of code with XXX git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@21536 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_dial.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'apps/app_dial.c') diff --git a/apps/app_dial.c b/apps/app_dial.c index a23398c97..160eeda29 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -714,7 +714,6 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags int cause; char numsubst[AST_MAX_EXTENSION]; char cidname[AST_MAX_EXTENSION]; - char toast[80]; char *l; int privdb_val = 0; unsigned int calldurationlimit = 0; @@ -1034,22 +1033,18 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags tmp->chan->appl = "AppDial"; tmp->chan->data = "(Outgoing Line)"; tmp->chan->whentohangup = 0; + if (tmp->chan->cid.cid_num) free(tmp->chan->cid.cid_num); - tmp->chan->cid.cid_num = NULL; + tmp->chan->cid.cid_num = ast_strdup(chan->cid.cid_num); + if (tmp->chan->cid.cid_name) free(tmp->chan->cid.cid_name); - tmp->chan->cid.cid_name = NULL; + tmp->chan->cid.cid_name = ast_strdup(chan->cid.cid_name); + if (tmp->chan->cid.cid_ani) free(tmp->chan->cid.cid_ani); - tmp->chan->cid.cid_ani = NULL; - - if (chan->cid.cid_num) - tmp->chan->cid.cid_num = strdup(chan->cid.cid_num); - if (chan->cid.cid_name) - tmp->chan->cid.cid_name = strdup(chan->cid.cid_name); - if (chan->cid.cid_ani) - tmp->chan->cid.cid_ani = strdup(chan->cid.cid_ani); + tmp->chan->cid.cid_ani = ast_strdup(chan->cid.cid_ani); /* Copy language from incoming to outgoing */ ast_string_field_set(tmp->chan, language, chan->language); @@ -1057,8 +1052,8 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags tmp->chan->cdrflags = chan->cdrflags; if (ast_strlen_zero(tmp->chan->musicclass)) ast_string_field_set(tmp->chan, musicclass, chan->musicclass); - if (chan->cid.cid_rdnis) - tmp->chan->cid.cid_rdnis = strdup(chan->cid.cid_rdnis); + /* XXX don't we free previous values ? */ + tmp->chan->cid.cid_rdnis = ast_strdup(chan->cid.cid_rdnis); /* Pass callingpres setting */ tmp->chan->cid.cid_pres = chan->cid.cid_pres; /* Pass type of number */ @@ -1511,15 +1506,20 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags } res = ast_bridge_call(chan,peer,&config); time(&end_time); - snprintf(toast, sizeof(toast), "%ld", (long)(end_time - answer_time)); - pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", toast); - + { + char toast[80]; + snprintf(toast, sizeof(toast), "%ld", (long)(end_time - answer_time)); + pbx_builtin_setvar_helper(chan, "ANSWEREDTIME", toast); + } } else { time(&end_time); res = -1; } - snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time)); - pbx_builtin_setvar_helper(chan, "DIALEDTIME", toast); + { + char toast[80]; + snprintf(toast, sizeof(toast), "%ld", (long)(end_time - start_time)); + pbx_builtin_setvar_helper(chan, "DIALEDTIME", toast); + } if (res != AST_PBX_NO_HANGUP_PEER) { if (!chan->_softhangup) -- cgit v1.2.3