mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-11 12:28:27 +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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user