diff options
author | Richard Mudgett <rmudgett@digium.com> | 2013-09-10 18:05:47 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2013-09-10 18:05:47 +0000 |
commit | 83bf017db9804c9274608ded72d70a72c086d756 (patch) | |
tree | a2f9a38495c75235101c86a3572529098fc5800f /main/indications.c | |
parent | 87cf916cdbcf16d244bd71d91ec5b849cc186923 (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 'main/indications.c')
-rw-r--r-- | main/indications.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/main/indications.c b/main/indications.c index 8d644e53e..2f2bdce62 100644 --- a/main/indications.c +++ b/main/indications.c @@ -341,12 +341,12 @@ int ast_playtones_start(struct ast_channel *chan, int vol, const char *playlst, } while ((s = strsep(&stringp, separator)) && !ast_strlen_zero(s)) { + struct playtones_item *new_items; struct ast_tone_zone_part tone_data = { .time = 0, }; s = ast_strip(s); - if (s[0]=='!') { s++; } else if (d.reppos == -1) { @@ -374,9 +374,12 @@ int ast_playtones_start(struct ast_channel *chan, int vol, const char *playlst, } } - if (!(d.items = ast_realloc(d.items, (d.nitems + 1) * sizeof(*d.items)))) { + new_items = ast_realloc(d.items, (d.nitems + 1) * sizeof(*d.items)); + if (!new_items) { + ast_free(d.items); return -1; } + d.items = new_items; d.items[d.nitems].fac1 = 2.0 * cos(2.0 * M_PI * (tone_data.freq1 / sample_rate)) * max_sample_val; d.items[d.nitems].init_v2_1 = sin(-4.0 * M_PI * (tone_data.freq1 / sample_rate)) * d.vol; |