]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix a memory leak related to the use of the "setvar" configuration option.
authorRussell Bryant <russell@russellbryant.com>
Tue, 16 Dec 2008 15:56:37 +0000 (15:56 +0000)
committerRussell Bryant <russell@russellbryant.com>
Tue, 16 Dec 2008 15:56:37 +0000 (15:56 +0000)
The problem was that these variables were being appended to the list of vars
on the sip_pvt every time a re-registration or re-subscription came in.
Since it's just a waste of memory to put them there unless the request was an
INVITE, then the fix is to check the request type before copying the vars.

(closes issue #14037)
Reported by: marvinek
Tested by: russell

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

channels/chan_sip.c

index 19cc9fd6a544a1e484a56a9ac9d3272c1cec886d..d478892da2087802596d24665725d4bdf716435b 100644 (file)
@@ -9566,11 +9566,13 @@ static enum check_auth_result check_user_full(struct sip_pvt *p, struct sip_requ
        if (user && ast_apply_ha(user->ha, sin)) {
                ast_copy_flags(&p->flags[0], &user->flags[0], SIP_FLAGS_TO_COPY);
                ast_copy_flags(&p->flags[1], &user->flags[1], SIP_PAGE2_FLAGS_TO_COPY);
-               /* copy channel vars */
-               for (v = user->chanvars ; v ; v = v->next) {
-                       if ((tmpvar = ast_variable_new(v->name, v->value))) {
-                               tmpvar->next = p->chanvars; 
-                               p->chanvars = tmpvar;
+               if (sipmethod == SIP_INVITE) {
+                       /* copy channel vars */
+                       for (v = user->chanvars ; v ; v = v->next) {
+                               if ((tmpvar = ast_variable_new(v->name, v->value))) {
+                                       tmpvar->next = p->chanvars; 
+                                       p->chanvars = tmpvar;
+                               }
                        }
                }
                p->prefs = user->prefs;
@@ -9724,11 +9726,13 @@ static enum check_auth_result check_user_full(struct sip_pvt *p, struct sip_requ
                                ast_string_field_set(p, peername, peer->name);
                                ast_string_field_set(p, authname, peer->name);
 
-                               /* copy channel vars */
-                               for (v = peer->chanvars ; v ; v = v->next) {
-                                       if ((tmpvar = ast_variable_new(v->name, v->value))) {
-                                               tmpvar->next = p->chanvars; 
-                                               p->chanvars = tmpvar;
+                               if (sipmethod == SIP_INVITE) {
+                                       /* copy channel vars */
+                                       for (v = peer->chanvars ; v ; v = v->next) {
+                                               if ((tmpvar = ast_variable_new(v->name, v->value))) {
+                                                       tmpvar->next = p->chanvars; 
+                                                       p->chanvars = tmpvar;
+                                               }
                                        }
                                }
                                if (authpeer) {