diff options
author | Richard Mudgett <rmudgett@digium.com> | 2013-09-10 18:05:47 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2013-09-10 18:05:47 +0000 |
commit | 83bf017db9804c9274608ded72d70a72c086d756 (patch) | |
tree | a2f9a38495c75235101c86a3572529098fc5800f /main/xmldoc.c | |
parent | 87cf916cdbcf16d244bd71d91ec5b849cc186923 (diff) |
Fix incorrect usages of ast_realloc().
There are several locations in the code base where this is done:
buf = ast_realloc(buf, new_size);
This is going to leak the original buf contents if the realloc fails.
Review: https://reviewboard.asterisk.org/r/2832/
........
Merged revisions 398757 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 398758 from http://svn.asterisk.org/svn/asterisk/branches/11
........
Merged revisions 398759 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@398760 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/xmldoc.c')
-rw-r--r-- | main/xmldoc.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/main/xmldoc.c b/main/xmldoc.c index 7ca66e12b..80e7830ae 100644 --- a/main/xmldoc.c +++ b/main/xmldoc.c @@ -607,8 +607,11 @@ static struct ast_xml_node *xmldoc_get_node(const char *type, const char *name, */ static void __attribute__((format(printf, 4, 5))) xmldoc_reverse_helper(int reverse, int *len, char **syntax, const char *fmt, ...) { - int totlen, tmpfmtlen; - char *tmpfmt, tmp; + int totlen; + int tmpfmtlen; + char *tmpfmt; + char *new_syntax; + char tmp; va_list ap; va_start(ap, fmt); @@ -621,12 +624,12 @@ static void __attribute__((format(printf, 4, 5))) xmldoc_reverse_helper(int reve tmpfmtlen = strlen(tmpfmt); totlen = *len + tmpfmtlen + 1; - *syntax = ast_realloc(*syntax, totlen); - - if (!*syntax) { + new_syntax = ast_realloc(*syntax, totlen); + if (!new_syntax) { ast_free(tmpfmt); return; } + *syntax = new_syntax; if (reverse) { memmove(*syntax + tmpfmtlen, *syntax, *len); |