mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
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
This commit is contained in:
parent
366f00a3d3
commit
6b8c94a6e3
5 changed files with 19 additions and 37 deletions
|
@ -80,8 +80,8 @@ void* skin_buffer_alloc(size_t size)
|
|||
{
|
||||
void *retval = NULL;
|
||||
#endif
|
||||
/* 32-bit aligned */
|
||||
size = (size + 3) & ~3;
|
||||
/* align to long which is enough for most types */
|
||||
size = (size + sizeof(long) - 1) & ~(sizeof(long) - 1);
|
||||
if (size > skin_buffer_freespace())
|
||||
{
|
||||
skin_error(MEMORY_LIMIT_EXCEEDED, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue