From bba84a3fa9a1af87f6a8080f9093f9277feb1292 Mon Sep 17 00:00:00 2001
From: "Graham Madarasz (Graham Linden)" <graham@lindenlab.com>
Date: Wed, 13 Mar 2013 13:38:30 -0700
Subject: [PATCH] Cleanup per code review of prev change with DaveP

---
 indra/llcommon/llmemory.h | 12 ++++++------
 indra/llmath/llvolume.cpp | 11 +++++++----
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 61e30f11cc1..d0e4bc9e25e 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -188,14 +188,14 @@ inline void ll_aligned_free_32(void *p)
 //
 inline void ll_memcpy_nonaliased_aligned_16(char* __restrict dst, const char* __restrict src, size_t bytes)
 {
-	assert(src != NULL);
-	assert(dst != NULL);
-	assert(bytes > 0);
-	assert((bytes % sizeof(F32))== 0); 
+	llassert(src != NULL);
+	llassert(dst != NULL);
+	llassert(bytes >= 16);
+	llassert((bytes % sizeof(F32))== 0); 
+	llassert((src < dst) ? ((src + bytes) < dst) : ((dst + bytes) < src));
+	llassert(bytes%16==0);
 	ll_assert_aligned(src,16);
 	ll_assert_aligned(dst,16);
-	assert((src < dst) ? ((src + bytes) < dst) : ((dst + bytes) < src));
-	assert(bytes%16==0);
 
 	char* end = dst + bytes;
 
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index cb5633c1bb1..edd16b5688d 100644
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -4729,11 +4729,13 @@ void LLVolumeFace::optimize(F32 angle_cutoff)
 		}
 	}
 
-	if (new_face.mNumVertices)
+	// disallow data amplification
+	//
+	if (new_face.mNumVertices <= mNumVertices)
 	{
-		llassert(new_face.mNumIndices == mNumIndices);
-		swapData(new_face);
-	}
+	    llassert(new_face.mNumIndices == mNumIndices);
+	    swapData(new_face);
+    }
 }
 
 class LLVCacheTriangleData;
@@ -6731,3 +6733,4 @@ void calc_binormal_from_triangle(LLVector4a& binormal,
 		binormal.set( 0, 1 , 0 );
 	}
 }
+
-- 
GitLab