]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
fixes reload Chan_dahdi memory leak caused by variables
authorJonathan Rose <jrose@digium.com>
Tue, 12 Apr 2011 18:12:29 +0000 (18:12 +0000)
committerJonathan Rose <jrose@digium.com>
Tue, 12 Apr 2011 18:12:29 +0000 (18:12 +0000)
chan_dahdi reloading with variables set via setvar in chan_dahdi.conf would
stay in the dahdi_pvt structs for individual channels (causing them to just
continue adding the new ones to the list) and also there was a memory leak
causes by the conf objects. This patch resolves both of these by using
ast_variables_destroy during the loading process.

(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/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.2@313432 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_dahdi.c

index 4ccd5687323aa8521aebb5fb97b52c19e5eb78e7..bb58df3ee4955d4c5a669ca1873a666dcd44fa73 100644 (file)
@@ -10540,6 +10540,12 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf,
        }
 
        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 @@ static int process_dahdi(struct dahdi_chan_conf *confp, const char *cat, struct
                } 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 */