[asterisk-commits] kmoore: trunk r382600 - /trunk/main/xmldoc.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 7 10:21:55 CST 2013


Author: kmoore
Date: Thu Mar  7 10:21:52 2013
New Revision: 382600

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382600
Log:
Resolve more memory leaks in xmldoc

Many places that allocated to pull out an attribute are now freed
properly.

Modified:
    trunk/main/xmldoc.c

Modified: trunk/main/xmldoc.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/xmldoc.c?view=diff&rev=382600&r1=382599&r2=382600
==============================================================================
--- trunk/main/xmldoc.c (original)
+++ trunk/main/xmldoc.c Thu Mar  7 10:21:52 2013
@@ -760,6 +760,7 @@
 				if ((paramtype = ast_xml_get_attribute(node, "required"))) {
 					if (!ast_true(paramtype)) {
 						optmidnode = 1;
+						ast_xml_free_attr(paramtype);
 						break;
 					}
 					ast_xml_free_attr(paramtype);
@@ -2347,16 +2348,22 @@
 	struct ast_xml_doc_item *item;
 
 	for (iter = ast_xml_node_get_children(cur); iter; iter = ast_xml_node_get_next(iter)) {
+		const char *iter_name;
 		if (strncasecmp(ast_xml_node_get_name(iter), "config", 6)) {
 			continue;
 		}
+		iter_name = ast_xml_get_attribute(iter, "name");
 		/* Now add all of the child config-related items to the list */
-		if (!(item = xmldoc_build_documentation_item(iter, ast_xml_get_attribute(iter, "name"), ast_xml_node_get_name(iter)))) {
-			ast_log(LOG_ERROR, "Could not build documentation for '%s:%s'\n", ast_xml_node_get_name(iter), ast_xml_get_attribute(iter, "name"));
+		if (!(item = xmldoc_build_documentation_item(iter, iter_name, ast_xml_node_get_name(iter)))) {
+			ast_log(LOG_ERROR, "Could not build documentation for '%s:%s'\n", ast_xml_node_get_name(iter), iter_name);
+			ast_xml_free_attr(iter_name);
 			break;
 		}
+		ast_xml_free_attr(iter_name);
 		if (!strcasecmp(ast_xml_node_get_name(iter), "configOption")) {
-			ast_string_field_set(item, ref, ast_xml_get_attribute(cur, "name"));
+			const char *name = ast_xml_get_attribute(cur, "name");
+			ast_string_field_set(item, ref, name);
+			ast_xml_free_attr(name);
 		}
 		(*tail)->next = item;
 		*tail = (*tail)->next;




More information about the asterisk-commits mailing list