Add additional assert to FixedSizeAllocatorWithCleanup (GH #745)

This assert checks the array we return to the caller is large enough. Spoiler alert... it is not always large enough, like on 64-bit AIX. The linker on AIX appears to align smaller than 8-bytes
This commit is contained in:
Jeffrey Walton 2018-11-21 23:04:00 -05:00
parent 1e8ac49b49
commit 6cf8895bf1
No known key found for this signature in database
GPG Key ID: B36AB348921B1838

View File

@ -500,7 +500,10 @@ private:
// for a large T, and that is what PAD achieves.
T* GetAlignedArray() {
T* p_array = (T*)(void*)(((byte*)m_array) + (0-(size_t)m_array)%16);
// Verify the 16-byte alignment
CRYPTOPP_ASSERT(IsAlignedOn(p_array, 16));
// Verify allocated array with pad is large enough.
CRYPTOPP_ASSERT(p_array+S <= m_array+(S+PAD));
return p_array;
}
// PAD is elements, not bytes, and rounded up to ensure no overflow.