aboutsummaryrefslogtreecommitdiffstats
path: root/frame.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-07-17 23:31:24 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-07-17 23:31:24 +0000
commitcb1944f8faeb29c6e3bd7e997ab9e81b292dea9c (patch)
tree577f068b6136d0d3b2a49443097275bc2997745a /frame.c
parent0b07fa3b77c4800b061abde8209a846e8e33f7ba (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: http://svn.digium.com/svn/asterisk/trunk@37830 f38db490-d61c-443f-a65b-d21fe96a405b
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;