[asterisk-commits] branch 1.2 r37828 - /branches/1.2/frame.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Jul 17 16:25:34 MST 2006
Author: russell
Date: Mon Jul 17 18:25:33 2006
New Revision: 37828
URL: http://svn.digium.com/view/asterisk?rev=37828&view=rev
Log:
if asked to duplicate a frame that has no data, don't set the frame's data
pointer past the end of the allocatted buffer for the new frame
Modified:
branches/1.2/frame.c
Modified: branches/1.2/frame.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/frame.c?rev=37828&r1=37827&r2=37828&view=diff
==============================================================================
--- branches/1.2/frame.c (original)
+++ branches/1.2/frame.c Mon Jul 17 18:25:33 2006
@@ -374,7 +374,7 @@
srclen = strlen(f->src);
if (srclen > 0)
len += srclen + 1;
- buf = malloc(len);
+ buf = calloc(1, len);
if (!buf)
return NULL;
out = buf;
@@ -387,16 +387,15 @@
out->delivery = f->delivery;
out->mallocd = AST_MALLOCD_HDR;
out->offset = AST_FRIENDLY_OFFSET;
- out->data = buf + sizeof(struct ast_frame) + AST_FRIENDLY_OFFSET;
+ if (out->datalen) {
+ out->data = buf + sizeof(struct ast_frame) + 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);
+ }
return out;
}
More information about the asterisk-commits
mailing list