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 /apps/recorder/jpeg_load.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 'apps/recorder/jpeg_load.c')
-rw-r--r-- | apps/recorder/jpeg_load.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/apps/recorder/jpeg_load.c b/apps/recorder/jpeg_load.c index 5b287aff75..34d543b56e 100644 --- a/apps/recorder/jpeg_load.c +++ b/apps/recorder/jpeg_load.c | |||
@@ -2024,7 +2024,7 @@ int clip_jpeg_fd(int fd, | |||
2024 | #else | 2024 | #else |
2025 | struct jpeg *p_jpeg = (struct jpeg*)bm->data; | 2025 | struct jpeg *p_jpeg = (struct jpeg*)bm->data; |
2026 | int tmp_size = maxsize; | 2026 | int tmp_size = maxsize; |
2027 | ALIGN_BUFFER(p_jpeg, tmp_size, sizeof(int)); | 2027 | ALIGN_BUFFER(p_jpeg, tmp_size, sizeof(long)); |
2028 | /* not enough memory for our struct jpeg */ | 2028 | /* not enough memory for our struct jpeg */ |
2029 | if ((size_t)tmp_size < sizeof(struct jpeg)) | 2029 | if ((size_t)tmp_size < sizeof(struct jpeg)) |
2030 | return -1; | 2030 | return -1; |
@@ -2133,7 +2133,7 @@ int clip_jpeg_fd(int fd, | |||
2133 | char *buf_end = (char *)bm->data + maxsize; | 2133 | char *buf_end = (char *)bm->data + maxsize; |
2134 | maxsize = buf_end - buf_start; | 2134 | maxsize = buf_end - buf_start; |
2135 | #ifndef JPEG_FROM_MEM | 2135 | #ifndef JPEG_FROM_MEM |
2136 | ALIGN_BUFFER(buf_start, maxsize, sizeof(uint32_t)); | 2136 | ALIGN_BUFFER(buf_start, maxsize, sizeof(long)); |
2137 | if (maxsize < (int)sizeof(struct jpeg)) | 2137 | if (maxsize < (int)sizeof(struct jpeg)) |
2138 | return -1; | 2138 | return -1; |
2139 | memmove(buf_start, p_jpeg, sizeof(struct jpeg)); | 2139 | memmove(buf_start, p_jpeg, sizeof(struct jpeg)); |