From 18cd1d226b15206a693bb9814da8e4806695712d Mon Sep 17 00:00:00 2001
From: Ivica Ico Bukvic <ico@vt.edu>
Date: Tue, 28 Jan 2014 23:12:27 -0500
Subject: [PATCH] fixed segfault regression in 4.datatructures/05.array.pd
 example where clicking on the scalar array in a subpatch would cause a
 segfault

---
 pd/src/g_array.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pd/src/g_array.c b/pd/src/g_array.c
index 7287a3414..4aeadbc33 100644
--- a/pd/src/g_array.c
+++ b/pd/src/g_array.c
@@ -1120,7 +1120,7 @@ int array_doclick(t_array *array, t_glist *glist, t_scalar *sc, t_array *ap,
                         // This, therefore takes into account whether we should count the center point
                         // of a bar or the starting point (poly) as our reference
                         // TODO: see if we can reimplement Bezier curves
-                        if (array_garray->x_style == PLOTSTYLE_POLY || array_garray->x_style == PLOTSTYLE_BEZ)
+                        if (array_garray != NULL && (array_garray->x_style == PLOTSTYLE_POLY || array_garray->x_style == PLOTSTYLE_BEZ))
                             array_motion(0, xpix - pxpix1, ypix - pypix);
                         else
                             array_motion(0, (xpix - (pxpix1 + (pxpix2 - pxpix1)/2)), ypix - pypix);
-- 
GitLab