summaryrefslogtreecommitdiff
path: root/funcs/func_dialgroup.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2013-09-10 18:05:47 +0000
committerRichard Mudgett <rmudgett@digium.com>2013-09-10 18:05:47 +0000
commit83bf017db9804c9274608ded72d70a72c086d756 (patch)
treea2f9a38495c75235101c86a3572529098fc5800f /funcs/func_dialgroup.c
parent87cf916cdbcf16d244bd71d91ec5b849cc186923 (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 'funcs/func_dialgroup.c')
-rw-r--r--funcs/func_dialgroup.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/funcs/func_dialgroup.c b/funcs/func_dialgroup.c
index 0e078cd80..37aba6afb 100644
--- a/funcs/func_dialgroup.c
+++ b/funcs/func_dialgroup.c
@@ -174,11 +174,17 @@ static int dialgroup_refreshdb(struct ast_channel *chan, const char *cdialgroup)
{
int len = 500, res = 0;
char *buf = NULL;
+ char *new_buf;
char *dialgroup = ast_strdupa(cdialgroup);
do {
len *= 2;
- buf = ast_realloc(buf, len);
+ new_buf = ast_realloc(buf, len);
+ if (!new_buf) {
+ ast_free(buf);
+ return -1;
+ }
+ buf = new_buf;
if ((res = dialgroup_read(chan, "", dialgroup, buf, len)) < 0) {
ast_free(buf);