From 75ffe90b0cf14559543e1719bf48fd0b397f3905 Mon Sep 17 00:00:00 2001
From: ruslantproductengine <ruslantproductengine@lindenlab.com>
Date: Mon, 27 Apr 2015 18:21:39 +0300
Subject: [PATCH] MAINT-5042 FIXED SL Viewer Closes Unexpectedly in specific
 area with high RenderVolumeLODFactor - fix for review - fix in buffer overrun
 detector

---
 indra/llcommon/llmemory.cpp |  3 +--
 indra/llcommon/llmemory.h   |  2 +-
 indra/llmath/llvolume.cpp   | 12 ++++++------
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index ae11988df8d..3a8eabac09a 100755
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -2176,8 +2176,7 @@ void* ll_aligned_malloc_fallback( size_t size, int align )
 	SYSTEM_INFO sysinfo;
 	GetSystemInfo(&sysinfo);
 	
-	unsigned int for_alloc = sysinfo.dwPageSize;
-	while(for_alloc < size) for_alloc += sysinfo.dwPageSize;
+	unsigned int for_alloc = (size/sysinfo.dwPageSize + !!(size%sysinfo.dwPageSize)) * sysinfo.dwPageSize;
 	
 	void *p = VirtualAlloc(NULL, for_alloc+sysinfo.dwPageSize, MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);
 	if(NULL == p) {
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index c4c9cc05661..fd09eb9debd 100755
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -97,7 +97,7 @@ template <typename T> T* LL_NEXT_ALIGNED_ADDRESS_64(T* address)
 //------------------------------------------------------------------------------------------------
 //------------------------------------------------------------------------------------------------
 	// for enable buffer overrun detection predefine LL_DEBUG_BUFFER_OVERRUN in current library
-	// change preprocessro code to: #if 1 && defined(LL_WINDOWS)
+	// change preprocessor code to: #if 1 && defined(LL_WINDOWS)
 
 #if 0 && defined(LL_WINDOWS)
 	void* ll_aligned_malloc_fallback( size_t size, int align );
diff --git a/indra/llmath/llvolume.cpp b/indra/llmath/llvolume.cpp
index c2198b91a7b..41ee3941ac7 100755
--- a/indra/llmath/llvolume.cpp
+++ b/indra/llmath/llvolume.cpp
@@ -5584,7 +5584,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 	{
 		resizeVertices(num_vertices+1);
 		
-		if (!partial_build)
+		//if (!partial_build)
 		{
 			resizeIndices(num_indices+3);
 		}
@@ -5592,7 +5592,7 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 	else
 	{
 		resizeVertices(num_vertices);
-		if (!partial_build)
+		//if (!partial_build)
 		{
 			resizeIndices(num_indices);
 		}
@@ -5714,10 +5714,10 @@ BOOL LLVolumeFace::createCap(LLVolume* volume, BOOL partial_build)
 		
 	LL_CHECK_MEMORY
 		
-	if (partial_build)
-	{
-		return TRUE;
-	}
+	//if (partial_build)
+	//{
+	//	return TRUE;
+	//}
 
 	if (mTypeMask & HOLLOW_MASK)
 	{
-- 
GitLab