Commits

Stinson Linden committed 464cf7a

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.

  • Participants
  • Parent commits ccb2916
  • Tags DRTVWR-233

Comments (0)

Files changed (1)

indra/llcommon/llmemory.h

 	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;