summaryrefslogtreecommitdiff
path: root/frame.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2006-07-17 23:31:24 +0000
committerRussell Bryant <russell@russellbryant.com>2006-07-17 23:31:24 +0000
commitda6910c35b2e72ce9cf6b06f4b1ceb1d62e5c975 (patch)
tree577f068b6136d0d3b2a49443097275bc2997745a /frame.c
parent6f6e7f6f031aa065ca7758b3da000d406c46befd (diff)
if asked to duplicate a frame that has no data, don't set the frame's data
pointer past the end of the buffer allocated for the new frame git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@37830 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'frame.c')
-rw-r--r--frame.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/frame.c b/frame.c
index 4774f2672..c2db41bad 100644
--- a/frame.c
+++ b/frame.c
@@ -375,7 +375,7 @@ struct ast_frame *ast_frdup(struct ast_frame *f)
srclen = strlen(f->src);
if (srclen > 0)
len += srclen + 1;
- if (!(buf = ast_malloc(len)))
+ if (!(buf = ast_calloc(1, len)))
return NULL;
out = buf;
/* Set us as having malloc'd header only, so it will eventually
@@ -387,16 +387,15 @@ struct ast_frame *ast_frdup(struct ast_frame *f)
out->delivery = f->delivery;
out->mallocd = AST_MALLOCD_HDR;
out->offset = AST_FRIENDLY_OFFSET;
- out->data = buf + sizeof(*out) + AST_FRIENDLY_OFFSET;
+ if (out->datalen) {
+ out->data = buf + sizeof(*out) + AST_FRIENDLY_OFFSET;
+ memcpy(out->data, f->data, out->datalen);
+ }
if (srclen > 0) {
out->src = out->data + f->datalen;
/* Must have space since we allocated for it */
strcpy((char *)out->src, f->src);
- } else
- out->src = NULL;
- out->prev = NULL;
- out->next = NULL;
- memcpy(out->data, f->data, out->datalen);
+ }
out->has_timing_info = f->has_timing_info;
if (f->has_timing_info) {
out->ts = f->ts;