aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_sms.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-20 01:28:14 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-20 01:28:14 +0000
commita6cd0e53d77948d34b54d8a6c16afe734fc60b17 (patch)
tree47348ce09925ddd2525352665c6b8e683bf2fb72 /apps/app_sms.c
parent4d2d1770934c5c4b3d13886565dc961499adc349 (diff)
fix up another place where the code made assumptions about how space for
variables would be allocatted on the stack git-svn-id: http://svn.digium.com/svn/asterisk/trunk@28934 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_sms.c')
-rw-r--r--apps/app_sms.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/apps/app_sms.c b/apps/app_sms.c
index c3488b911..105bbe387 100644
--- a/apps/app_sms.c
+++ b/apps/app_sms.c
@@ -1176,14 +1176,13 @@ static void sms_messagetx(sms_t * h)
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 @@ static int sms_generate (struct ast_channel *chan, void *data, int len, int samp
MAXSAMPLES, samples);
samples = MAXSAMPLES;
}
- len = samples * SAMPLE2LEN;
+ len = samples * SAMPLE2LEN + AST_FRIENDLY_OFFSET;
+ buf = alloca(len);
- waste[0] = 0; /* make compiler happy */
f.frametype = AST_FRAME_VOICE;
#ifdef OUTALAW
f.subclass = AST_FORMAT_ALAW;
@@ -1204,7 +1203,7 @@ static int sms_generate (struct ast_channel *chan, void *data, int len, int samp
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 */