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/event.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/event.c')
-rw-r--r-- | main/event.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/main/event.c b/main/event.c index 0f0406f55..d183e585e 100644 --- a/main/event.c +++ b/main/event.c @@ -311,13 +311,17 @@ static int event_append_ie_raw(struct ast_event **event, enum ast_event_ie_type const void *data, size_t data_len) { struct ast_event_ie *ie; + struct ast_event *old_event; unsigned int extra_len; uint16_t event_len; event_len = ntohs((*event)->event_len); extra_len = sizeof(*ie) + data_len; - if (!(*event = ast_realloc(*event, event_len + extra_len))) { + old_event = *event; + *event = ast_realloc(*event, event_len + extra_len); + if (!*event) { + ast_free(old_event); return -1; } |