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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@398758 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2013-09-10 17:56:56 +00:00
parent 72a07f9646
commit d8b4adb590
8 changed files with 118 additions and 52 deletions

View File

@@ -578,8 +578,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);
@@ -592,12 +595,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);