From 159de683e88624b2bda3634f5401081b9af6303b Mon Sep 17 00:00:00 2001 From: Router Gray Date: Fri, 24 Apr 2020 07:16:18 -0500 Subject: [PATCH] Correct a logical OR in llrender, and add guards against mCount dropping below zero. (Alchemy and LL sync) --- indra/llrender/llrender.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index f1d099bc0..86a6fba75 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -2146,7 +2146,7 @@ void LLRender::setLineWidth(F32 line_width) } if (mNewContext.lineWidth != line_width || mDirty) { - if (mMode == LLRender::LINES || LLRender::LINE_STRIP) + if (mMode == LLRender::LINES || mMode == LLRender::LINE_STRIP) { flush(); } @@ -2492,7 +2492,8 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, S32 vert_count) mColorsp[mCount] = mColorsp[mCount-1]; } - 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]; mPrimitiveReset = false; } @@ -2528,9 +2529,12 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, S32 mCount++; mColorsp[mCount] = mColorsp[mCount-1]; } - - mVerticesp[mCount] = mVerticesp[mCount-1]; - mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; + + if (mCount > 0) + { + mVerticesp[mCount] = mVerticesp[mCount - 1]; + mTexcoordsp[mCount] = mTexcoordsp[mCount - 1]; + } mPrimitiveReset = false; } @@ -2564,9 +2568,12 @@ void LLRender::vertexBatchPreTransformed(LLVector4a* verts, LLVector2* uvs, LLCo mColorsp.copyArray(mCount, colors, vert_count); mCount += vert_count; - mVerticesp[mCount] = mVerticesp[mCount-1]; - mTexcoordsp[mCount] = mTexcoordsp[mCount-1]; - mColorsp[mCount] = mColorsp[mCount-1]; + if (mCount > 0) + { + mVerticesp[mCount] = mVerticesp[mCount - 1]; + mTexcoordsp[mCount] = mTexcoordsp[mCount - 1]; + mColorsp[mCount] = mColorsp[mCount - 1]; + } mPrimitiveReset = false; }