From a84d52ffcb08bfc4fc6168aed29514475f9d8b3c Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Fri, 11 Nov 2016 23:11:40 -0500
Subject: [PATCH] *fixed multipatching segfault and improved 4th variant of
 multipatching logic.

---
 pd/src/g_editor.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c
index 19ab93151..1d05bb26e 100644
--- a/pd/src/g_editor.c
+++ b/pd/src/g_editor.c
@@ -4475,6 +4475,8 @@ int canvas_trymulticonnect(t_canvas *x, int xpos, int ypos, int which, int doit)
                                     x, y1, sel->sel_what,
                                     closest1, closest2, 1, 1);
                             }
+                            else
+                                closest1--;
                         }
                     }
                 }
@@ -4488,7 +4490,7 @@ int canvas_trymulticonnect(t_canvas *x, int xpos, int ypos, int which, int doit)
                         if (sel->sel_what != y1 && sel->sel_what != y2)
                         {
                             ob1 = pd_checkobject(&sel->sel_what->g_pd);
-                            noutlet1 = obj_ninlets(ob1);
+                            noutlet1 = obj_noutlets(ob1);
                             closest2++;
                             if (closest2 >= ninlet2)
                             {
@@ -4500,6 +4502,8 @@ int canvas_trymulticonnect(t_canvas *x, int xpos, int ypos, int which, int doit)
                                     x, sel->sel_what, y2,
                                     closest1, closest2, 1, 1);
                             }
+                            else
+                                closest2--;
                         }
                     }
                 }            
-- 
GitLab