diff options
author | William Todd Stinson <stinson@lindenlab.com> | 2012-10-18 17:36:57 -0700 |
---|---|---|
committer | William Todd Stinson <stinson@lindenlab.com> | 2012-10-18 17:36:57 -0700 |
commit | 11017315e6f0cdcc247a875e41d027beac8df764 (patch) | |
tree | 78606abe4c74718160a6da8ec0ec078df67d0893 /indra/llcommon | |
parent | a7f6dcaef7fb49901a2ebf0629e3089fa8cdad98 (diff) |
MAINT-1753: Correcting behavior of ll_aligned_realloc_16() on Linux to avoid memory corruption in the case that the new memory size requested is smaller than the old memory size. Also, adding check to ensure that the aligned malloc returns a non-null value before memcopying.
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/llmemory.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 40cde485cf..10013e0f92 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -87,7 +87,11 @@ inline void* ll_aligned_realloc_16(void* ptr, size_t size, size_t old_size) // r void* ret = ll_aligned_malloc_16(size); if (ptr) { - memcpy(ret, ptr, old_size); + if (ret) + { + // Only copy the size of the smallest memory block to avoid memory corruption. + memcpy(ret, ptr, llmin(old_size, size)); + } ll_aligned_free_16(ptr); } return ret; |