[asterisk-commits] mjordan: branch 11 r375756 - /branches/11/main/xmldoc.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sat Nov 3 19:47:21 CDT 2012
Author: mjordan
Date: Sat Nov 3 19:47:17 2012
New Revision: 375756
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=375756
Log:
Fix memory leaks in XML documentation
This patch fixes two memory leaks:
1) When building XML documentation items, the 'name' attribute was extracted
from XML elements but not properly freed after being copied into the item
being built.
2) When unloading XML documentation, the doctree container objects were not
properly freed.
This patch corrects these memory leaks. Note that this patch was modified
slightly for this commmit, as the case where the 'name' attribute doesn't
exist also wasn't handled in the item construction. This patch also checks
for that attribute not existing.
(closes issue ASTERISK-20648)
Reported by: Corey Farrell
Tested by: mjordan
patches:
xmldoc-memory_leak.patch uploaded by Corey Farrell (license 5909)
Modified:
branches/11/main/xmldoc.c
Modified: branches/11/main/xmldoc.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/xmldoc.c?view=diff&rev=375756&r1=375755&r2=375756
==============================================================================
--- branches/11/main/xmldoc.c (original)
+++ branches/11/main/xmldoc.c Sat Nov 3 19:47:17 2012
@@ -2250,6 +2250,9 @@
continue;
}
name = ast_xml_get_attribute(node, "name");
+ if (!name) {
+ continue;
+ }
switch (xmldoc_get_syntax_type(type)) {
case MANAGER_EVENT_SYNTAX:
@@ -2275,6 +2278,7 @@
default:
item = xmldoc_build_documentation_item(node, name, type);
}
+ ast_xml_free_attr(name);
if (item) {
ao2_link(docs, item);
@@ -2334,12 +2338,13 @@
/*! \brief Close and unload XML documentation. */
static void xmldoc_unload_documentation(void)
{
- struct documentation_tree *doctree;
+ struct documentation_tree *doctree;
AST_RWLIST_WRLOCK(&xmldoc_tree);
while ((doctree = AST_RWLIST_REMOVE_HEAD(&xmldoc_tree, entry))) {
ast_free(doctree->filename);
ast_xml_close(doctree->doc);
+ ast_free(doctree);
}
AST_RWLIST_UNLOCK(&xmldoc_tree);
More information about the asterisk-commits
mailing list