aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authormurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2007-03-30 17:57:47 +0000
committermurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2007-03-30 17:57:47 +0000
commit1b0e01605bbb55ed8ca5b0a7cada5eaf7f315ae2 (patch)
tree50f307ee74a41fa6d78b4a152b390570f3cc988e /main
parent757bcc9075780a3163e790ae36bf159bc9d1cd3e (diff)
Merged revisions 59522 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r59522 | murf | 2007-03-30 11:51:17 -0600 (Fri, 30 Mar 2007) | 1 line several changes via kpflemings review ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@59523 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/cdr.c31
-rw-r--r--main/channel.c2
-rw-r--r--main/pbx.c5
3 files changed, 28 insertions, 10 deletions
diff --git a/main/cdr.c b/main/cdr.c
index 6502e8c18..be2385212 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -170,8 +170,11 @@ void ast_cdr_unregister(const char *name)
*/
struct ast_cdr *ast_cdr_dup(struct ast_cdr *cdr)
{
- struct ast_cdr *newcdr = ast_cdr_alloc();
-
+ struct ast_cdr *newcdr;
+
+ if (!cdr) /* don't die if we get a null cdr pointer */
+ return NULL;
+ newcdr = ast_cdr_alloc();
if (!newcdr)
return NULL;
@@ -221,6 +224,9 @@ void ast_cdr_getvar(struct ast_cdr *cdr, const char *name, char **ret, char *wor
const char *fmt = "%Y-%m-%d %T";
const char *varbuf;
+ if (!cdr) /* don't die if the cdr is null */
+ return;
+
*ret = NULL;
/* special vars (the ones from the struct ast_cdr when requested by name)
I'd almost say we should convert all the stringed vals to vars */
@@ -292,6 +298,9 @@ int ast_cdr_setvar(struct ast_cdr *cdr, const char *name, const char *value, int
struct varshead *headp;
int x;
+ if (!cdr) /* don't die if the cdr is null */
+ return -1;
+
for (x = 0; cdr_readonly_vars[x]; x++) {
if (!strcasecmp(name, cdr_readonly_vars[x])) {
ast_log(LOG_ERROR, "Attempt to set the '%s' read-only variable!.\n", name);
@@ -332,6 +341,9 @@ int ast_cdr_copy_vars(struct ast_cdr *to_cdr, struct ast_cdr *from_cdr)
const char *var, *val;
int x = 0;
+ if (!to_cdr || !from_cdr) /* don't die if one of the pointers is null */
+ return 0;
+
headpa = &from_cdr->varshead;
headpb = &to_cdr->varshead;
@@ -408,6 +420,8 @@ void ast_cdr_free_vars(struct ast_cdr *cdr, int recur)
/*! \brief print a warning if cdr already posted */
static void check_post(struct ast_cdr *cdr)
{
+ if (!cdr)
+ return;
if (ast_test_flag(cdr, AST_CDR_FLAG_POSTED))
ast_log(LOG_NOTICE, "CDR on channel '%s' already posted\n", S_OR(cdr->channel, "<unknown>"));
}
@@ -415,6 +429,8 @@ static void check_post(struct ast_cdr *cdr)
/*! \brief print a warning if cdr already started */
static void check_start(struct ast_cdr *cdr)
{
+ if (!cdr)
+ return;
if (!ast_tvzero(cdr->start))
ast_log(LOG_NOTICE, "CDR on channel '%s' already started\n", S_OR(cdr->channel, "<unknown>"));
}
@@ -452,7 +468,10 @@ void ast_cdr_discard(struct ast_cdr *cdr)
struct ast_cdr *ast_cdr_alloc(void)
{
- return ast_calloc(1, sizeof(struct ast_cdr));
+ struct ast_cdr *x = ast_calloc(1, sizeof(struct ast_cdr));
+ if (!x)
+ ast_log(LOG_ERROR,"Allocation Failure for a CDR!\n");
+ return x;
}
void ast_cdr_merge(struct ast_cdr *to, struct ast_cdr *from)
@@ -651,7 +670,8 @@ static void set_one_cid(struct ast_cdr *cdr, struct ast_channel *c)
{
/* Grab source from ANI or normal Caller*ID */
const char *num = S_OR(c->cid.cid_ani, c->cid.cid_num);
-
+ if (!cdr)
+ return;
if (!ast_strlen_zero(c->cid.cid_name)) {
if (!ast_strlen_zero(num)) /* both name and number */
snprintf(cdr->clid, sizeof(cdr->clid), "\"%s\" <%s>", c->cid.cid_name, num);
@@ -1002,6 +1022,9 @@ void ast_cdr_detach(struct ast_cdr *cdr)
struct ast_cdr_batch_item *newtail;
int curr;
+ if (!cdr)
+ return;
+
/* maybe they disabled CDR stuff completely, so just drop it */
if (!enabled) {
if (option_debug)
diff --git a/main/channel.c b/main/channel.c
index 7238b5fd3..998843d7e 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -732,7 +732,7 @@ struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_
tmp->uniqueid);
}
- /* Experiment: under what conditions do we NOT want to track cdrs on channels? */
+ /* Reminder for the future: under what conditions do we NOT want to track cdrs on channels? */
tmp->cdr = ast_cdr_alloc();
ast_cdr_init(tmp->cdr, tmp);
ast_cdr_start(tmp->cdr);
diff --git a/main/pbx.c b/main/pbx.c
index d8aef64df..2ce76054d 100644
--- a/main/pbx.c
+++ b/main/pbx.c
@@ -4940,11 +4940,6 @@ static int ast_pbx_outgoing_cdr_failed(void)
return -1; /* failure */
if (!chan->cdr) {
- chan->cdr = ast_cdr_alloc(); /* allocate a cdr for the channel */
- ast_log(LOG_NOTICE, "=====PBX_OUTGOING_CDR_FAILED ALLOCS CHANNEL CDR for %s\n", chan->name);
- }
-
- if (!chan->cdr) {
/* allocation of the cdr failed */
ast_channel_free(chan); /* free the channel */
return -1; /* return failure */