summaryrefslogtreecommitdiff
path: root/secblock.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2020-12-29 01:49:17 -0500
committerJeffrey Walton <noloader@gmail.com>2020-12-29 01:49:17 -0500
commit4bc7408ae2aefac9357c16809541ecbe225b7f3a (patch)
treed8b265cfc7c287f21bedf9df668446ddd1ddfb8a /secblock.h
parent9fe5ccfbeed3c3c48b6e1d42e4abb64d11662527 (diff)
downloadcryptopp-git-4bc7408ae2aefac9357c16809541ecbe225b7f3a.tar.gz
Use 8-byte alignment for FixedSizeAllocatorWithCleanup when 16-byte alignment is false (GH #992)
Diffstat (limited to 'secblock.h')
-rw-r--r--secblock.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/secblock.h b/secblock.h
index 9be03050..39beb677 100644
--- a/secblock.h
+++ b/secblock.h
@@ -547,9 +547,14 @@ private:
#else
- // CRYPTOPP_BOOL_ALIGN16 is 0. Use natural alignment of T.
+ // CRYPTOPP_BOOL_ALIGN16 is 0. Normally we would use the natural
+ // alignment of T. The problem we are having is, some toolchains
+ // are changing the boundary for 64-bit arrays. 64-bit elements
+ // require 8-byte alignment, but the toolchain is laying the array
+ // out on a 4 byte boundary. See GH #992 for mystery alignment:
+ // https://github.com/weidai11/cryptopp/issues/992
T* GetAlignedArray() {return m_array;}
- T m_array[S];
+ CRYPTOPP_ALIGN_DATA(8) T m_array[S];
#endif
@@ -700,9 +705,14 @@ public:
private:
- // T_Align16 is false. Use natural alignment of T.
+ // T_Align16 is false. Normally we would use the natural
+ // alignment of T. The problem we are having is, some toolchains
+ // are changing the boundary for 64-bit arrays. 64-bit elements
+ // require 8-byte alignment, but the toolchain is laying the array
+ // out on a 4 byte boundary. See GH #992 for mystery alignment:
+ // https://github.com/weidai11/cryptopp/issues/992
T* GetAlignedArray() {return m_array;}
- T m_array[S];
+ CRYPTOPP_ALIGN_DATA(8) T m_array[S];
A m_fallbackAllocator;
bool m_allocated;