From 720f543caa9cdefbc92273a419d17bb6441b027e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Michaud?= <jfmichaud31@gmail.com>
Date: Fri, 12 Oct 2018 19:12:01 -0400
Subject: [PATCH] Added a fail condition to prevent a crash

---
 modules/csg/csg_shape.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp
index d1ef08dc835..44044d2750b 100644
--- a/modules/csg/csg_shape.cpp
+++ b/modules/csg/csg_shape.cpp
@@ -521,6 +521,11 @@ CSGBrush *CSGMesh::_build_brush() {
 
 		Array arrays = mesh->surface_get_arrays(i);
 
+		if (arrays.size() == 0) {
+			_make_dirty();
+			ERR_FAIL_COND_V(arrays.size() == 0, NULL);
+		}
+
 		PoolVector<Vector3> avertices = arrays[Mesh::ARRAY_VERTEX];
 		if (avertices.size() == 0)
 			continue;