[svn-commits] seanbright: trunk r196622 - /trunk/cdr/cdr_manager.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue May 26 07:14:18 CDT 2009


Author: seanbright
Date: Tue May 26 07:14:14 2009
New Revision: 196622

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=196622
Log:
Use a properly allocated channel for substitution in cdr_manager.

Modified:
    trunk/cdr/cdr_manager.c

Modified: trunk/cdr/cdr_manager.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/cdr/cdr_manager.c?view=diff&rev=196622&r1=196621&r2=196622
==============================================================================
--- trunk/cdr/cdr_manager.c (original)
+++ trunk/cdr/cdr_manager.c Tue May 26 07:14:14 2009
@@ -127,7 +127,6 @@
 	char strAnswerTime[80] = "";
 	char strEndTime[80] = "";
 	char buf[CUSTOM_FIELDS_BUF_SIZE];
-	struct ast_channel dummy;
 
 	if (!enablecdr)
 		return 0;
@@ -146,9 +145,14 @@
 	buf[0] = 0;
 	/* Custom fields handling */
 	if (customfields != NULL && ast_str_strlen(customfields)) {
-		memset(&dummy, 0, sizeof(dummy));
-		dummy.cdr = cdr;
-		pbx_substitute_variables_helper(&dummy, ast_str_buffer(customfields), buf, sizeof(buf) - 1);
+		struct ast_channel *dummy = ast_channel_alloc(0, 0, "", "", "", "", "", 0, "Substitution/%p", cdr);
+		if (!dummy) {
+			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",




More information about the svn-commits mailing list