[asterisk-commits] seanbright: branch 1.6.2 r241019 - in	/branches/1.6.2: ./ main/config.c
    SVN commits to the Asterisk project 
    asterisk-commits at lists.digium.com
       
    Mon Jan 18 14:01:59 CST 2010
    
    
  
Author: seanbright
Date: Mon Jan 18 14:01:50 2010
New Revision: 241019
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=241019
Log:
Merged revisions 241016 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk
................
  r241016 | seanbright | 2010-01-18 14:57:52 -0500 (Mon, 18 Jan 2010) | 19 lines
  
  Merged revisions 241015 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r241015 | seanbright | 2010-01-18 14:54:19 -0500 (Mon, 18 Jan 2010) | 12 lines
    
    Plug a memory leak when reading configs with their comments.
    
    While reading through configuration files with the intent of returning their
    full contents (comments specifically) we allocated some memory and then forgot
    to free it.  This doesn't fix 16554 but clears up a leak I had in the lab.
    
    (issue #16554)
    Reported by: mav3rick
    Patches:
          issue16554_20100118.patch uploaded by seanbright (license 71)
    Tested by: seanbright
  ........
................
Modified:
    branches/1.6.2/   (props changed)
    branches/1.6.2/main/config.c
Propchange: branches/1.6.2/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.
Modified: branches/1.6.2/main/config.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/main/config.c?view=diff&rev=241019&r1=241018&r2=241019
==============================================================================
--- branches/1.6.2/main/config.c (original)
+++ branches/1.6.2/main/config.c Mon Jan 18 14:01:50 2010
@@ -382,6 +382,18 @@
 	}
 }
 
+static void ast_comment_destroy(struct ast_comment **comment)
+{
+	struct ast_comment *n, *p;
+
+	for (p = *comment; p; p = n) {
+		n = p->next;
+		ast_free(p);
+	}
+
+	*comment = NULL;
+}
+
 void ast_variables_destroy(struct ast_variable *v)
 {
 	struct ast_variable *vn;
@@ -389,6 +401,9 @@
 	while (v) {
 		vn = v;
 		v = v->next;
+		ast_comment_destroy(&vn->precomments);
+		ast_comment_destroy(&vn->sameline);
+		ast_comment_destroy(&vn->trailing);
 		ast_free(vn);
 	}
 }
@@ -535,27 +550,6 @@
 	}
 }
 
-static void ast_destroy_comments(struct ast_category *cat)
-{
-	struct ast_comment *n, *p;
-
-	for (p=cat->precomments; p; p=n) {
-		n = p->next;
-		free(p);
-	}
-	for (p=cat->sameline; p; p=n) {
-		n = p->next;
-		free(p);
-	}
-	for (p=cat->trailing; p; p=n) {
-		n = p->next;
-		free(p);
-	}
-	cat->precomments = NULL;
-	cat->sameline = NULL;
-	cat->trailing = NULL;
-}
-
 static void ast_destroy_template_list(struct ast_category *cat)
 {
 	struct ast_category_template_instance *x;
@@ -571,7 +565,9 @@
 		free(cat->file);
 		cat->file = 0;
 	}
-	ast_destroy_comments(cat);
+	ast_comment_destroy(&cat->precomments);
+	ast_comment_destroy(&cat->sameline);
+	ast_comment_destroy(&cat->trailing);
 	ast_destroy_template_list(cat);
 	ast_free(cat);
 }
    
    
More information about the asterisk-commits
mailing list