[asterisk-commits] kharwell: branch 1.8 r398060 - in /branches/1.8: main/manager.c res/res_agi.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 30 12:50:06 CDT 2013


Author: kharwell
Date: Fri Aug 30 12:50:03 2013
New Revision: 398060

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=398060
Log:
Memory leak fix

ast_xmldoc_printable returns an allocated block that must be freed by the
caller.  Fixed manager.c and res_agi.c to stop leaking these results.

(closes issue ASTERISK-22395)
Reported by: Corey Farrell
Patches:
     manager-leaks-1.8.patch uploaded by coreyfarrell (license 5909)
     res_agi-xmldoc-leaks.patch uploaded by coreyfarrell (license 5909)

Modified:
    branches/1.8/main/manager.c
    branches/1.8/res/res_agi.c

Modified: branches/1.8/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/manager.c?view=diff&rev=398060&r1=398059&r2=398060
==============================================================================
--- branches/1.8/main/manager.c (original)
+++ branches/1.8/main/manager.c Fri Aug 30 12:50:03 2013
@@ -1512,17 +1512,22 @@
 			if (!strcasecmp(cur->action, a->argv[num])) {
 #ifdef AST_XML_DOCS
 				if (cur->docsrc == AST_XML_DOC) {
+					char *syntax = ast_xmldoc_printable(S_OR(cur->syntax, "Not available"), 1);
+					char *synopsis = ast_xmldoc_printable(S_OR(cur->synopsis, "Not available"), 1);
+					char *description = ast_xmldoc_printable(S_OR(cur->description, "Not available"), 1);
+					char *arguments = ast_xmldoc_printable(S_OR(cur->arguments, "Not available"), 1);
+					char *seealso = ast_xmldoc_printable(S_OR(cur->seealso, "Not available"), 1);
 					ast_cli(a->fd, "%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n%s%s\n\n",
-						syntax_title,
-						ast_xmldoc_printable(S_OR(cur->syntax, "Not available"), 1),
-						synopsis_title,
-						ast_xmldoc_printable(S_OR(cur->synopsis, "Not available"), 1),
-						description_title,
-						ast_xmldoc_printable(S_OR(cur->description, "Not available"), 1),
-						arguments_title,
-						ast_xmldoc_printable(S_OR(cur->arguments, "Not available"), 1),
-						seealso_title,
-						ast_xmldoc_printable(S_OR(cur->seealso, "Not available"), 1));
+						syntax_title, syntax,
+						synopsis_title, synopsis,
+						description_title, description,
+						arguments_title, arguments,
+						seealso_title, seealso);
+					ast_free(syntax);
+					ast_free(synopsis);
+					ast_free(description);
+					ast_free(arguments);
+					ast_free(seealso);
 				} else
 #endif
 				{

Modified: branches/1.8/res/res_agi.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/res/res_agi.c?view=diff&rev=398060&r1=398059&r2=398060
==============================================================================
--- branches/1.8/res/res_agi.c (original)
+++ branches/1.8/res/res_agi.c Fri Aug 30 12:50:03 2013
@@ -3760,9 +3760,6 @@
 
 	AST_RWLIST_RDLOCK(&agi_commands);
 	AST_RWLIST_TRAVERSE(&agi_commands, command, list) {
-#ifdef AST_XML_DOCS
-		char *stringptmp;
-#endif
 		char *tempstr, *stringp;
 
 		if (!command->cmda[0])	/* end ? */
@@ -3775,8 +3772,7 @@
 		fprintf(htmlfile, "<TR><TD><TABLE BORDER=\"1\" CELLPADDING=\"5\" WIDTH=\"100%%\">\n");
 		fprintf(htmlfile, "<TR><TH ALIGN=\"CENTER\"><B>%s - %s</B></TH></TR>\n", fullcmd, command->summary);
 #ifdef AST_XML_DOCS
-		stringptmp = ast_xmldoc_printable(command->usage, 0);
-		stringp = ast_strdup(stringptmp);
+		stringp = ast_xmldoc_printable(command->usage, 0);
 #else
 		stringp = ast_strdup(command->usage);
 #endif
@@ -3794,9 +3790,6 @@
 		fprintf(htmlfile, "</TD></TR>\n");
 		fprintf(htmlfile, "</TABLE></TD></TR>\n\n");
 		ast_free(stringp);
-#ifdef AST_XML_DOCS
-		ast_free(stringptmp);
-#endif
 	}
 	AST_RWLIST_UNLOCK(&agi_commands);
 	fprintf(htmlfile, "</TABLE>\n</BODY>\n</HTML>\n");




More information about the asterisk-commits mailing list