Enforce alignment even if buffer is not aligned
This commit is contained in:
parent
4d8db4ab10
commit
82a5de7bf7
1 changed files with 7 additions and 0 deletions
|
@ -555,6 +555,13 @@ int memory_buffer_alloc_init( unsigned char *buf, size_t len )
|
||||||
platform_set_malloc_free( buffer_alloc_malloc, buffer_alloc_free );
|
platform_set_malloc_free( buffer_alloc_malloc, buffer_alloc_free );
|
||||||
#endif
|
#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.buf = buf;
|
||||||
heap.len = len;
|
heap.len = len;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue