[asterisk-commits] mjordan: trunk r371493 - in /trunk: ./ main/xmldoc.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 17 15:52:47 CDT 2012


Author: mjordan
Date: Fri Aug 17 15:52:43 2012
New Revision: 371493

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=371493
Log:
Fix memory leak in XML documentation

When formatting documentation fields, the XML documentation parser calls
xmldoc_get_formatted.  This function allocates a string buffer at the
beginning of its routine.  Unfortunately, on certain code paths, it also
calls xmldoc_string_cleanup, which assumes that it will create the string
buffer.  The previously allocated string buffer is then leaked by the
xmldoc_string_cleanup routine.

Now: we don't do that.

(closes issue AST-932)
Reported by: Alexander Homig
........

Merged revisions 371469 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 371491 from http://svn.asterisk.org/svn/asterisk/branches/10
........

Merged revisions 371492 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/main/xmldoc.c

Propchange: trunk/
------------------------------------------------------------------------------
--- branch-11-merged (original)
+++ branch-11-merged Fri Aug 17 15:52:43 2012
@@ -1,1 +1,1 @@
-/branches/11:1-371121,371143,371146,371200,371227,371258,371272,371295,371324,371355,371382,371395,371399,371425-371426,371438,371482
+/branches/11:1-371121,371143,371146,371200,371227,371258,371272,371295,371324,371355,371382,371395,371399,371425-371426,371438,371482,371492

Modified: trunk/main/xmldoc.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/xmldoc.c?view=diff&rev=371493&r1=371492&r2=371493
==============================================================================
--- trunk/main/xmldoc.c (original)
+++ trunk/main/xmldoc.c Fri Aug 17 15:52:43 2012
@@ -1944,14 +1944,16 @@
 {
 	struct ast_xml_node *tmp;
 	const char *notcleanret, *tmpstr;
-	struct ast_str *ret = ast_str_create(128);
+	struct ast_str *ret;
 
 	if (raw_output) {
+		/* xmldoc_string_cleanup will allocate the ret object */
 		notcleanret = ast_xml_get_text(node);
 		tmpstr = notcleanret;
 		xmldoc_string_cleanup(ast_skip_blanks(notcleanret), &ret, 0);
 		ast_xml_free_text(tmpstr);
 	} else {
+		ret = ast_str_create(128);
 		for (tmp = ast_xml_node_get_children(node); tmp; tmp = ast_xml_node_get_next(tmp)) {
 			/* if found, parse a <para> element. */
 			if (xmldoc_parse_common_elements(tmp, "", "\n", &ret)) {




More information about the asterisk-commits mailing list