mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
Use a properly allocated channel for substitution in cdr_manager.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@196622 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -127,7 +127,6 @@ static int manager_log(struct ast_cdr *cdr)
|
|||||||
char strAnswerTime[80] = "";
|
char strAnswerTime[80] = "";
|
||||||
char strEndTime[80] = "";
|
char strEndTime[80] = "";
|
||||||
char buf[CUSTOM_FIELDS_BUF_SIZE];
|
char buf[CUSTOM_FIELDS_BUF_SIZE];
|
||||||
struct ast_channel dummy;
|
|
||||||
|
|
||||||
if (!enablecdr)
|
if (!enablecdr)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -146,9 +145,14 @@ static int manager_log(struct ast_cdr *cdr)
|
|||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
/* Custom fields handling */
|
/* Custom fields handling */
|
||||||
if (customfields != NULL && ast_str_strlen(customfields)) {
|
if (customfields != NULL && ast_str_strlen(customfields)) {
|
||||||
memset(&dummy, 0, sizeof(dummy));
|
struct ast_channel *dummy = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Substitution/%p", cdr);
|
||||||
dummy.cdr = cdr;
|
if (!dummy) {
|
||||||
pbx_substitute_variables_helper(&dummy, ast_str_buffer(customfields), buf, sizeof(buf) - 1);
|
ast_log(LOG_ERROR, "Unable to allocate channel for variable substitution.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
dummy->cdr = ast_cdr_dup(cdr);
|
||||||
|
pbx_substitute_variables_helper(dummy, ast_str_buffer(customfields), buf, sizeof(buf) - 1);
|
||||||
|
ast_channel_release(dummy);
|
||||||
}
|
}
|
||||||
|
|
||||||
manager_event(EVENT_FLAG_CDR, "Cdr",
|
manager_event(EVENT_FLAG_CDR, "Cdr",
|
||||||
|
Reference in New Issue
Block a user