]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 371491 via svnmerge from
authorAutomerge script <automerge@asterisk.org>
Fri, 17 Aug 2012 21:21:43 +0000 (21:21 +0000)
committerAutomerge script <automerge@asterisk.org>
Fri, 17 Aug 2012 21:21:43 +0000 (21:21 +0000)
file:///srv/subversion/repos/asterisk/branches/10

................
  r371491 | mjordan | 2012-08-17 15:21:30 -0500 (Fri, 17 Aug 2012) | 17 lines

  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
................

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10-digiumphones@371504 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/xmldoc.c

index f83f58a6534207279558dab6e2767795c384de25..6e2d90c59d5964d359715e78ff93501853ba6baa 100644 (file)
@@ -1798,14 +1798,16 @@ static struct ast_str *xmldoc_get_formatted(struct ast_xml_node *node, int raw_o
 {
        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_para(tmp, "", "\n", &ret)) {