From: Kevin Harwell Date: Fri, 30 Aug 2013 17:50:03 +0000 (+0000) Subject: Memory leak fix X-Git-Tag: 1.8.24.0-rc1~30 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3c840c1224f1510dc1ae07673f538264e950a056;p=thirdparty%2Fasterisk.git 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) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@398060 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/manager.c b/main/manager.c index 9b8986b238..4e4c206f47 100644 --- a/main/manager.c +++ b/main/manager.c @@ -1512,17 +1512,22 @@ static char *handle_showmancmd(struct ast_cli_entry *e, int cmd, struct ast_cli_ 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 { diff --git a/res/res_agi.c b/res/res_agi.c index 19e3280e70..1a35355147 100644 --- a/res/res_agi.c +++ b/res/res_agi.c @@ -3760,9 +3760,6 @@ static int write_htmldump(const char *filename) 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 @@ static int write_htmldump(const char *filename) fprintf(htmlfile, "\n"); fprintf(htmlfile, "\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 @@ static int write_htmldump(const char *filename) fprintf(htmlfile, "\n"); fprintf(htmlfile, "
%s - %s
\n\n"); ast_free(stringp); -#ifdef AST_XML_DOCS - ast_free(stringptmp); -#endif } AST_RWLIST_UNLOCK(&agi_commands); fprintf(htmlfile, "\n\n\n");