issue #5763
authorKevin P. Fleming <kpfleming@digium.com>
Wed, 16 Nov 2005 18:21:10 +0000 (18:21 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Wed, 16 Nov 2005 18:21:10 +0000 (18:21 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7118 65c4cc65-6c06-0410-ace0-fbb531ad65f3

ChangeLog
apps/app_forkcdr.c

index f1e03b1..1c988f3 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2005-11-16  Kevin P. Fleming  <kpfleming@limerick.digium.com>
 
+       * apps/app_forkcdr.c (forkcdr_exec): issue warning (and don't segfault) if ForkCDR is called on a channel that doesn't have a CDR (issue #5763)
+
        * channel.c (ast_queue_hangup): ensure that the channel lock is held before changing its fields... (issue #5770)
 
        * res/res_musiconhold.c: don't spit out incorrect log messages (and leak memory) during reload (issue #5766)
index 21073ff..290c168 100755 (executable)
@@ -59,8 +59,7 @@ static void ast_cdr_fork(struct ast_channel *chan)
        struct ast_cdr *newcdr;
        struct ast_flags flags = { AST_CDR_FLAG_KEEP_VARS };
 
-       if (!chan || !(cdr = chan->cdr))
-               return;
+       cdr = chan->cdr;
 
        while (cdr->next)
                cdr = cdr->next;
@@ -79,11 +78,18 @@ static void ast_cdr_fork(struct ast_channel *chan)
 
 static int forkcdr_exec(struct ast_channel *chan, void *data)
 {
-       int res=0;
+       int res = 0;
        struct localuser *u;
+
+       if (!chan->cdr) {
+               ast_log(LOG_WARNING, "Channel does not have a CDR\n");
+               return 0;
+       }
+
        LOCAL_USER_ADD(u);
+
        if (!ast_strlen_zero(data))
-               ast_set2_flag(chan->cdr, strchr((char *)data, 'v'), AST_CDR_FLAG_KEEP_VARS);
+               ast_set2_flag(chan->cdr, strchr(data, 'v'), AST_CDR_FLAG_KEEP_VARS);
        
        ast_cdr_fork(chan);