mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-10 11:58:08 +00:00
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:
13
main/heap.c
13
main/heap.c
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user