diff options
author | Matthew Jordan <mjordan@digium.com> | 2012-08-17 20:52:43 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2012-08-17 20:52:43 +0000 |
commit | eedab0744b622dfa902b57f83a4a20670c3ce437 (patch) | |
tree | d0b5cfbe216b0b55a004c241927cd53fb0d27712 | |
parent | 1a95c9a906e9548a04d91fe77d77216a93e30df9 (diff) |
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
........
Merged revisions 371491 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 371492 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@371493 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r-- | main/xmldoc.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/main/xmldoc.c b/main/xmldoc.c index e8383511e..bb5afe056 100644 --- a/main/xmldoc.c +++ b/main/xmldoc.c @@ -1944,14 +1944,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_common_elements(tmp, "", "\n", &ret)) { |