From 7c5e92cec57f492c465ec075cd8297fb86aed3c5 Mon Sep 17 00:00:00 2001
From: Callum Prentice <callum@gmail.com>
Date: Mon, 13 Mar 2017 11:13:43 -0700
Subject: SL-644 Add guard to mCount in LLRender.cpp

---
 indra/llrender/llrender.cpp | 49 +++++----------------------------------------
 1 file changed, 5 insertions(+), 44 deletions(-)

diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp
index 77c5921c9c..76f28bb43f 100644
--- a/indra/llrender/llrender.cpp
+++ b/indra/llrender/llrender.cpp
@@ -1829,48 +1829,6 @@ void LLRender::flush()
 {
 	if (mCount > 0)
 	{
-#if 0
-		if (!glIsEnabled(GL_VERTEX_ARRAY))
-		{
-			LL_ERRS() << "foo 1" << LL_ENDL;
-		}
-
-		if (!glIsEnabled(GL_COLOR_ARRAY))
-		{
-			LL_ERRS() << "foo 2" << LL_ENDL;
-		}
-
-		if (!glIsEnabled(GL_TEXTURE_COORD_ARRAY))
-		{
-			LL_ERRS() << "foo 3" << LL_ENDL;
-		}
-
-		if (glIsEnabled(GL_NORMAL_ARRAY))
-		{
-			LL_ERRS() << "foo 7" << LL_ENDL;
-		}
-
-		GLvoid* pointer;
-
-		glGetPointerv(GL_VERTEX_ARRAY_POINTER, &pointer);
-		if (pointer != &(mBuffer[0].v))
-		{
-			LL_ERRS() << "foo 4" << LL_ENDL;
-		}
-
-		glGetPointerv(GL_COLOR_ARRAY_POINTER, &pointer);
-		if (pointer != &(mBuffer[0].c))
-		{
-			LL_ERRS() << "foo 5" << LL_ENDL;
-		}
-
-		glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER, &pointer);
-		if (pointer != &(mBuffer[0].uv))
-		{
-			LL_ERRS() << "foo 6" << LL_ENDL;
-		}
-#endif
-				
 		if (!mUIOffset.empty())
 		{
 			sUICalls++;
@@ -2104,8 +2062,11 @@ void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, S32 v
 		}
 	}
 
-	mVerticesp[mCount] = mVerticesp[mCount-1];
-	mTexcoordsp[mCount] = mTexcoordsp[mCount-1];
+	if (mCount > 0)
+	{
+		mVerticesp[mCount] = mVerticesp[mCount - 1];
+		mTexcoordsp[mCount] = mTexcoordsp[mCount - 1];
+	}
 }
 
 void LLRender::vertexBatchPreTransformed(LLVector3* verts, LLVector2* uvs, LLColor4U* colors, S32 vert_count)
-- 
cgit v1.2.3