From c4e21cf2828517e761657eb70bf516d84f17fc77 Mon Sep 17 00:00:00 2001
From: Nicky <sl.nicky.ml@googlemail.com>
Date: Sun, 24 Apr 2016 12:55:13 +0200
Subject: [PATCH] Fix a crash is drawn vertices is 0. (transplanted from
 89b3e585218ddb8d6a3e62af29f8daf889371e5e)

---
 indra/llrender/llrender.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 69420dd0bb3..0e242a20f69 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -2039,7 +2039,8 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, S32 vert_count)
 		}
 	}
 
-	mVerticesp[mCount] = mVerticesp[mCount-1];
+	if( mCount > 0 ) // ND: Guard against crashes if mCount is zero, yes it can happen
+		mVerticesp[mCount] = mVerticesp[mCount-1];
 }
 
 void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 vert_count)
-- 
GitLab