From 3270b6735b7e27e84a1d476d8b90d95788e6349e Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Wed, 22 Jul 2020 12:10:38 -0400
Subject: [PATCH] port from Vanilla: fix crasher bug in clone_free()

Vanilla commit ab4750bd39964efd5c9a32fdaf9fb300d0d2f5d7
---
 pd/src/g_clone.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/pd/src/g_clone.c b/pd/src/g_clone.c
index ade8cddd5..8eba7ba15 100644
--- a/pd/src/g_clone.c
+++ b/pd/src/g_clone.c
@@ -167,14 +167,13 @@ static void clone_free(t_clone *x)
         {
             canvas_closebang(x->x_vec[i].c_gl);
             pd_free(&x->x_vec[i].c_gl->gl_pd);
+            t_freebytes(x->x_outvec[i],
+                x->x_nout * sizeof(*x->x_outvec[i]));
         }
         t_freebytes(x->x_vec, x->x_n * sizeof(*x->x_vec));
         t_freebytes(x->x_argv, x->x_argc * sizeof(*x->x_argv));
         t_freebytes(x->x_invec, x->x_nin * sizeof(*x->x_invec));
-        for (i = 0; i < x->x_nout; i++)
-            t_freebytes(x->x_outvec[i],
-                x->x_nout * sizeof(*x->x_outvec[i]));
-        t_freebytes(x->x_outvec, x->x_nout * sizeof(*x->x_outvec));
+        t_freebytes(x->x_outvec, x->x_n * sizeof(*x->x_outvec));
     }
 }
 
-- 
GitLab