[asterisk-commits] trunk r37830 - /trunk/frame.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Jul 17 16:31:24 MST 2006


Author: russell
Date: Mon Jul 17 18:31:24 2006
New Revision: 37830

URL: http://svn.digium.com/view/asterisk?rev=37830&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 buffer allocated for the new frame

Modified:
    trunk/frame.c

Modified: trunk/frame.c
URL: http://svn.digium.com/view/asterisk/trunk/frame.c?rev=37830&r1=37829&r2=37830&view=diff
==============================================================================
--- trunk/frame.c (original)
+++ trunk/frame.c Mon Jul 17 18:31:24 2006
@@ -375,7 +375,7 @@
 		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 @@
 	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;



More information about the asterisk-commits mailing list