From 0b6566dff02a7103f10b979b7cc708efff33e097 Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Fri, 20 Sep 2019 01:03:03 -0400
Subject: [PATCH] at least keep the inoperable streamout13~ and streamin13~
 from crashing

---
 externals/ext13/streamin13~.c  | 18 +++++++++++-------
 externals/ext13/streamout13~.c | 10 +++++-----
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/externals/ext13/streamin13~.c b/externals/ext13/streamin13~.c
index 32ac03b20..9ef6bc308 100644
--- a/externals/ext13/streamin13~.c
+++ b/externals/ext13/streamin13~.c
@@ -187,7 +187,8 @@ static t_int *streamin13_perform(t_int *w)
    for (i=0;i < x->x_n;i++) {
       out[i] = (t_float *)(w[offset+i]);
    }
-   if (x->x_connectsocket){
+
+   if (x->x_connectsocket >= 0){
 	     timeout.tv_sec = 0;
 	     timeout.tv_usec = 0;
 	
@@ -210,8 +211,11 @@ static t_int *streamin13_perform(t_int *w)
 	            }
 	         }
 	       }
-	 free(out);	      
-	 return (w+offset+1+i);
+
+#ifdef _WIN32
+	 free(out);
+#endif
+	 return (w+offset+i);
 	     } else {
 	        x->x_ndone++;
 	     }
@@ -276,7 +280,7 @@ static t_int *streamin13_perform(t_int *w)
 #ifdef _WIN32
 	free(out);
 #endif 
-     return (w+offset+1+i);
+     return (w+offset+i);
 }
 	
 	
@@ -284,14 +288,14 @@ static t_int *streamin13_perform(t_int *w)
 static void streamin13_dsp(t_streamin13 *x, t_signal **sp)
 {
   int i;
-  t_int** myvec = getbytes(sizeof(t_int)*(x->x_n + 3));
+  t_int** myvec = getbytes(sizeof(t_int)*(x->x_n + 2));
    
   myvec[0] = (t_int*)x;
   myvec[1] = (t_int*)sp[0]->s_n;
   for (i=0;i < x->x_n;i++)
     myvec[2 + i] = (t_int*)sp[i]->s_vec;
-  dsp_addv(streamin13_perform, (t_int)(x->x_n + 3), (t_int*)myvec);
-  freebytes(myvec,sizeof(t_int)*(x->x_n + 3));
+  dsp_addv(streamin13_perform, x->x_n + 2, (t_int*)myvec);
+  freebytes(myvec,sizeof(t_int)*(x->x_n + 2));
 
 }
 
diff --git a/externals/ext13/streamout13~.c b/externals/ext13/streamout13~.c
index 714c1b0e3..817583248 100644
--- a/externals/ext13/streamout13~.c
+++ b/externals/ext13/streamout13~.c
@@ -172,7 +172,6 @@ static t_int *streamout13_perform(t_int *w)
       in[i] = (t_float *)(w[offset+i]);
     }
 
-
    if (x->x_fd > 0){
 
      if (n != x->nsamples)
@@ -272,7 +271,7 @@ static t_int *streamout13_perform(t_int *w)
 #ifdef _WIN32
   free(in);
 #endif
-  return (w + 2 + i * 2);
+  return (w + 3 + i);
 }
 
 static void streamout13_dsp(t_streamout13 *x, t_signal **sp)
@@ -280,15 +279,16 @@ static void streamout13_dsp(t_streamout13 *x, t_signal **sp)
 /*
     dsp_add(streamout13_perform, 3, x, sp[0]->s_vec, (t_int)sp[0]->s_n);
 */
+
   int i;
-  t_int** myvec = getbytes(sizeof(t_int)*(x->x_n + 3));
+  t_int** myvec = getbytes(sizeof(t_int)*(x->x_n + 2));
    
   myvec[0] = (t_int*)x;
   myvec[1] = (t_int*)sp[0]->s_n;
   for (i=0;i < x->x_n/*+1*/;i++)
     myvec[2 + i] = (t_int*)sp[i]->s_vec;
-  dsp_addv(streamout13_perform, (t_int)(x->x_n + 3), (t_int*)myvec);
-  freebytes(myvec,sizeof(t_int)*(x->x_n + 3));
+  dsp_addv(streamout13_perform, x->x_n + 2, (t_int *)myvec);
+  freebytes(myvec,sizeof(t_int)*(x->x_n + 2));
 }
 
 static void streamout13_grain(t_streamout13 *x,t_floatarg grain)
-- 
GitLab