Enforce alignment even if buffer is not aligned
diff --git a/library/memory_buffer_alloc.c b/library/memory_buffer_alloc.c
index caeaa46..7dfeda9 100644
--- a/library/memory_buffer_alloc.c
+++ b/library/memory_buffer_alloc.c
@@ -555,6 +555,13 @@
     platform_set_malloc_free( buffer_alloc_malloc, buffer_alloc_free );
 #endif
 
+    if( (size_t) buf % POLARSSL_MEMORY_ALIGN_MULTIPLE )
+    {
+        buf += POLARSSL_MEMORY_ALIGN_MULTIPLE
+             - (size_t) buf % POLARSSL_MEMORY_ALIGN_MULTIPLE;
+        len -= (size_t) buf % POLARSSL_MEMORY_ALIGN_MULTIPLE;
+    }
+
     heap.buf = buf;
     heap.len = len;