From 3d759745f99201921db91aa42ffa757a37bb2190 Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Thu, 17 Aug 2006 16:22:58 +0000 Subject: [PATCH] Use the last CDR entry instead of the first CDR entry for variable retrieving variables using the CDR dialplan function. (issue #7689 reported by voipgate) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2@40225 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- funcs/func_cdr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/funcs/func_cdr.c b/funcs/func_cdr.c index 3e4696e18d..fdd241894b 100644 --- a/funcs/func_cdr.c +++ b/funcs/func_cdr.c @@ -44,11 +44,12 @@ static char *builtin_function_cdr_read(struct ast_channel *chan, char *cmd, char int argc; char *argv[2]; int recursive = 0; + struct ast_cdr *cdr = chan->cdr; if (ast_strlen_zero(data)) return NULL; - if (!chan->cdr) + if (!cdr) return NULL; mydata = ast_strdupa(data); @@ -61,7 +62,11 @@ static char *builtin_function_cdr_read(struct ast_channel *chan, char *cmd, char recursive = 1; } - ast_cdr_getvar(chan->cdr, argv[0], &ret, buf, len, recursive); + /* Find last entry */ + while (cdr->next) + cdr = cdr->next; + + ast_cdr_getvar(cdr, argv[0], &ret, buf, len, recursive); return ret; } -- 2.47.2