diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2022-05-02 15:23:37 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-05-02 15:38:48 +0100 |
commit | 6b8c94a6e3094ab75fcfe319fa2bc100f4e329ec (patch) | |
tree | 6c6ee0a2e7f77084f721ed33ff5b8856ec43fb61 /lib/skin_parser/skin_buffer.c | |
parent | 366f00a3d3dc6517e7dcb1bbebb887c4f795320b (diff) | |
download | rockbox-6b8c94a6e3094ab75fcfe319fa2bc100f4e329ec.tar.gz rockbox-6b8c94a6e3094ab75fcfe319fa2bc100f4e329ec.zip |
Fix some non-portable alignment values
UBSan reports an avalanche of unaligned pointer bugs stemming from
hardcoded 4-byte alignments used in certain places. Use sizeof(long)
instead to align to the machine word size.
Change-Id: I28e505212462c5268afa24e95df3a103ac3e2213
Diffstat (limited to 'lib/skin_parser/skin_buffer.c')
-rw-r--r-- | lib/skin_parser/skin_buffer.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/skin_parser/skin_buffer.c b/lib/skin_parser/skin_buffer.c index d18122ef20..021746ba82 100644 --- a/lib/skin_parser/skin_buffer.c +++ b/lib/skin_parser/skin_buffer.c | |||
@@ -80,8 +80,8 @@ void* skin_buffer_alloc(size_t size) | |||
80 | { | 80 | { |
81 | void *retval = NULL; | 81 | void *retval = NULL; |
82 | #endif | 82 | #endif |
83 | /* 32-bit aligned */ | 83 | /* align to long which is enough for most types */ |
84 | size = (size + 3) & ~3; | 84 | size = (size + sizeof(long) - 1) & ~(sizeof(long) - 1); |
85 | if (size > skin_buffer_freespace()) | 85 | if (size > skin_buffer_freespace()) |
86 | { | 86 | { |
87 | skin_error(MEMORY_LIMIT_EXCEEDED, NULL); | 87 | skin_error(MEMORY_LIMIT_EXCEEDED, NULL); |