[asterisk-commits] trunk r28934 - /trunk/apps/app_sms.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri May 19 18:28:14 MST 2006


Author: russell
Date: Fri May 19 20:28:14 2006
New Revision: 28934

URL: http://svn.digium.com/view/asterisk?rev=28934&view=rev
Log:
fix up another place where the code made assumptions about how space for
variables would be allocatted on the stack

Modified:
    trunk/apps/app_sms.c

Modified: trunk/apps/app_sms.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_sms.c?rev=28934&r1=28933&r2=28934&view=diff
==============================================================================
--- trunk/apps/app_sms.c (original)
+++ trunk/apps/app_sms.c Fri May 19 20:28:14 2006
@@ -1176,14 +1176,13 @@
 static int sms_generate (struct ast_channel *chan, void *data, int len, int samples)
 {
 	struct ast_frame f = { 0 };
-	unsigned char waste[AST_FRIENDLY_OFFSET];
 #define MAXSAMPLES (800)
 #ifdef OUTALAW
-	unsigned char buf[MAXSAMPLES];
+	unsigned char *buf;
 #else
-	signed short buf[MAXSAMPLES];
+	short *buf;
 #endif
-#define SAMPLE2LEN (sizeof (buf[0]))
+#define SAMPLE2LEN sizeof(*buf)
 	sms_t *h = data;
 	int i;
 
@@ -1192,9 +1191,9 @@
 			 MAXSAMPLES, samples);
 		samples = MAXSAMPLES;
 	}
-	len = samples * SAMPLE2LEN;
-
-	waste[0] = 0;				 /* make compiler happy */
+	len = samples * SAMPLE2LEN + AST_FRIENDLY_OFFSET;
+	buf = alloca(len);
+
 	f.frametype = AST_FRAME_VOICE;
 #ifdef OUTALAW
 	f.subclass = AST_FORMAT_ALAW;
@@ -1204,7 +1203,7 @@
 	f.datalen = len;
 	f.offset = AST_FRIENDLY_OFFSET;
 	f.mallocd = 0;
-	f.data = buf;
+	f.data = buf + AST_FRIENDLY_OFFSET;
 	f.samples = samples;
 	f.src = "app_sms";
 	/* create a buffer containing the digital sms pattern */



More information about the asterisk-commits mailing list