Hi,


This patch fixes a couple of segfaults in music-on-hold,
frame smoother routines and channel allocation in Asterisk.
Mark, feel free to apply it in CVS (if approved).

Regards,
Michael.


Index: channel.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channel.c,v
retrieving revision 1.25
diff -u -r1.25 channel.c
--- channel.c   4 Jul 2003 16:49:11 -0000       1.25
+++ channel.c   8 Jul 2003 10:48:13 -0000
@@ -279,8 +279,8 @@
                return NULL;
        PTHREAD_MUTEX_LOCK(&chlock);
        tmp = malloc(sizeof(struct ast_channel));
-       memset(tmp, 0, sizeof(struct ast_channel));
        if (tmp) {
+               memset(tmp, 0, sizeof(struct ast_channel));
                pvt = malloc(sizeof(struct ast_channel_pvt));
                if (pvt) {
                        memset(pvt, 0, sizeof(struct ast_channel_pvt));
Index: frame.c
===================================================================
RCS file: /usr/cvsroot/asterisk/frame.c,v
retrieving revision 1.3
diff -u -r1.3 frame.c
--- frame.c     28 Jun 2003 16:40:02 -0000      1.3
+++ frame.c     8 Jul 2003 10:48:15 -0000
@@ -125,8 +125,10 @@
        /* Make frame */
        s->f.frametype = AST_FRAME_VOICE;
        s->f.subclass = s->format;
-       s->f.data = s->framedata + AST_FRIENDLY_OFFSET;
-       s->f.offset = AST_FRIENDLY_OFFSET;
+       /*s->f.data = s->framedata + AST_FRIENDLY_OFFSET;*/
+       s->f.data = s->framedata;
+       /*s->f.offset = AST_FRIENDLY_OFFSET;*/
+       s->f.offset = 0;
        s->f.datalen = s->size;
        s->f.samples = s->size * s->samplesperbyte;
        /* Fill Data */
@@ -141,7 +143,8 @@
 
 void ast_smoother_free(struct ast_smoother *s)
 {
-       free(s);
+       if (s != NULL)
+               free(s);
 }
 
 static struct ast_frame *ast_frame_header_new(void)
Index: apps/Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/Makefile,v
retrieving revision 1.8
diff -u -r1.8 Makefile
--- apps/Makefile       16 May 2003 20:57:12 -0000      1.8
+++ apps/Makefile       8 Jul 2003 10:48:15 -0000
@@ -35,7 +35,7 @@
 all: $(APPS)
 
 clean:
-       rm -f *.so *.o look
+       rm -f *.so *.o look .depend
 
 %.so : %.o
        $(CC) -shared -Xlinker -x -o $@ $<
Index: res/res_musiconhold.c
===================================================================
RCS file: /usr/cvsroot/asterisk/res/res_musiconhold.c,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 res_musiconhold.c
--- res/res_musiconhold.c       18 Mar 2003 06:00:18 -0000      1.1.1.5
+++ res/res_musiconhold.c       8 Jul 2003 10:48:30 -0000
@@ -400,7 +400,8 @@
                ast_log(LOG_WARNING, "Only doing %d of %d requested bytes on %s\n", 
sizeof(buf), len, chan->name);
                len = sizeof(buf);
        }
-       res = read(moh->pipe[0], buf + AST_FRIENDLY_OFFSET/2, len);
+       /* XXX SEGFAULT res = read(moh->pipe[0], buf + AST_FRIENDLY_OFFSET/2, len);*/
+       res = read(moh->pipe[0], buf, len);
 #if 0
        if (res != len) {
                ast_log(LOG_WARNING, "Read only %d of %d bytes: %s\n", res, len, 
strerror(errno));
@@ -413,7 +414,8 @@
                f.mallocd = 0;
                f.datalen = res;
                f.samples = res / 2;
-               f.data = buf + AST_FRIENDLY_OFFSET / 2;
+               /* XXX SEGFAULT f.data = buf + AST_FRIENDLY_OFFSET / 2;*/
+               f.data = buf;
                f.offset = AST_FRIENDLY_OFFSET;
                if (ast_write(chan, &f)< 0) {
                        ast_log(LOG_WARNING, "Failed to write frame to '%s': %s\n", 
chan->name, strerror(errno));

Reply via email to