[asterisk-commits] jrose: branch 1.6.2 r313432 - /branches/1.6.2/channels/chan_dahdi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 12 13:12:35 CDT 2011


Author: jrose
Date: Tue Apr 12 13:12:29 2011
New Revision: 313432

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=313432
Log:
fixes a chan_dahdi reload memory leak that occurs when there are channel variables

reload chan_dahdi would cause variables to spill over from the previous config into the current config as 
well as add any variables in the new config (if left the same, full on duplication) This patch purges variables 
from pvts when they are reconfigured as well as from the configuration pvt once the configuration has been loaded.

(closes issue #17450)
Reported by: nahuelgreco
Patches:
      patch.diff uploaded by jrose (license 1225)
Tested by: tilghman, jrose

Review: https://reviewboard.asterisk.org/r/1170/

Modified:
    branches/1.6.2/channels/chan_dahdi.c

Modified: branches/1.6.2/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/channels/chan_dahdi.c?view=diff&rev=313432&r1=313431&r2=313432
==============================================================================
--- branches/1.6.2/channels/chan_dahdi.c (original)
+++ branches/1.6.2/channels/chan_dahdi.c Tue Apr 12 13:12:29 2011
@@ -10540,6 +10540,12 @@
 	}
 
 	if (tmp) {
+		/* If there are variables in tmp before it is updated to match the new config, clear them */
+		if (reloading && tmp->vars) {
+			ast_variables_destroy(tmp->vars);
+			tmp->vars = NULL;
+		}
+
 		int chan_sig = conf->chan.sig;
 		if (!here) {
 			if ((channel != CHAN_PSEUDO) && !pri) {
@@ -18111,6 +18117,13 @@
 		} else if (!(options & PROC_DAHDI_OPT_NOWARN) )
 			ast_log(LOG_WARNING, "Ignoring any changes to '%s' (on reload) at line %d.\n", v->name, v->lineno);
 	}
+
+	/* Since confp has already filled invidual dahdi_pvt objects with channels at this point, clear the variables in confp's pvt. */
+	if (confp->chan.vars) {
+		ast_variables_destroy(confp->chan.vars);
+		confp->chan.vars = NULL;
+	}	
+
 	if (dahdichan[0]) {
 		/* The user has set 'dahdichan' */
 		/*< \todo pass proper line number instead of 0 */




More information about the asterisk-commits mailing list