Structs alignment in memory, fixes device freezes/crashes

This commit is contained in:
Alexandre Paillier
2022-05-05 15:21:39 +02:00
parent d43849d852
commit 5c00a5c27b
5 changed files with 44 additions and 14 deletions

View File

@@ -3,6 +3,7 @@
#include "encode_field.h"
#include "path.h"
#include "mem.h"
#include "mem_utils.h"
#include "eip712.h"
#include "shared_context.h"
@@ -12,7 +13,7 @@ bool field_hash_init(void)
{
if (fh == NULL)
{
if ((fh = mem_alloc(sizeof(*fh))) == NULL)
if ((fh = MEM_ALLOC_AND_ALIGN_TO_TYPE(sizeof(*fh), *fh)) == NULL)
{
return false;
}
@@ -36,7 +37,6 @@ bool field_hash(const uint8_t *data,
#endif
(void)data;
if (fh == NULL)
{
return false;