summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2016-09-06 10:04:19 -0400
committerOz Linden <oz@lindenlab.com>2016-09-06 10:04:19 -0400
commita5adabb4f6660144345ddbd0b647130fd2ca6461 (patch)
tree74238912b521967a456292d11b2a8ecd8874cba5 /indra/llcommon
parent53f9fbcfb7090372b781e1b73c1458174cc7c761 (diff)
add protections against failed memory allocations in VBO and aligned memory
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llmemory.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h
index 0fb257aab1..575edddc43 100644
--- a/indra/llcommon/llmemory.h
+++ b/indra/llcommon/llmemory.h
@@ -110,11 +110,15 @@ template <typename T> T* LL_NEXT_ALIGNED_ADDRESS_64(T* address)
#if defined(LL_WINDOWS)
return _aligned_malloc(size, align);
#else
+ char* aligned = NULL;
void* mem = malloc( size + (align - 1) + sizeof(void*) );
- char* aligned = ((char*)mem) + sizeof(void*);
- aligned += align - ((uintptr_t)aligned & (align - 1));
+ if (mem)
+ {
+ aligned = ((char*)mem) + sizeof(void*);
+ aligned += align - ((uintptr_t)aligned & (align - 1));
- ((void**)aligned)[-1] = mem;
+ ((void**)aligned)[-1] = mem;
+ }
return aligned;
#endif
}