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
This commit is contained in:
parent
0b07fa3b77
commit
cb1944f8fa
13
frame.c
13
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;
|
||||
|
|
Reference in New Issue