diff options
author | Oz Linden <oz@lindenlab.com> | 2016-09-06 10:04:19 -0400 |
---|---|---|
committer | Oz Linden <oz@lindenlab.com> | 2016-09-06 10:04:19 -0400 |
commit | a5adabb4f6660144345ddbd0b647130fd2ca6461 (patch) | |
tree | 74238912b521967a456292d11b2a8ecd8874cba5 /indra/llcommon | |
parent | 53f9fbcfb7090372b781e1b73c1458174cc7c761 (diff) |
add protections against failed memory allocations in VBO and aligned memory
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/llmemory.h | 10 |
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 } |