Skip to content
Snippets Groups Projects
Commit 11017315 authored by William Todd Stinson's avatar William Todd Stinson
Browse files

MAINT-1753: Correcting behavior of ll_aligned_realloc_16() on Linux to avoid...

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.
parent a7f6dcae
No related branches found
No related tags found
No related merge requests found
...@@ -87,7 +87,11 @@ inline void* ll_aligned_realloc_16(void* ptr, size_t size, size_t old_size) // r ...@@ -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); void* ret = ll_aligned_malloc_16(size);
if (ptr) 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); ll_aligned_free_16(ptr);
} }
return ret; return ret;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment