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/


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@398757 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2013-09-10 17:53:58 +00:00
parent ac043540cc
commit 303d6c56f9
8 changed files with 118 additions and 52 deletions

View File

@@ -181,18 +181,19 @@ static int grow_heap(struct ast_heap *h
#endif
)
{
h->avail_len = h->avail_len * 2 + 1;
void **new_heap;
size_t new_len = h->avail_len * 2 + 1;
if (!(h->heap =
#ifdef MALLOC_DEBUG
__ast_realloc(h->heap, h->avail_len * sizeof(void *), file, lineno, func)
new_heap = __ast_realloc(h->heap, new_len * sizeof(void *), file, lineno, func);
#else
ast_realloc(h->heap, h->avail_len * sizeof(void *))
new_heap = ast_realloc(h->heap, new_len * sizeof(void *));
#endif
)) {
h->cur_len = h->avail_len = 0;
if (!new_heap) {
return -1;
}
h->heap = new_heap;
h->avail_len = new_len;
return 0;
}