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:
Aidan MacDonald 2022-05-02 15:23:37 +01:00
parent 366f00a3d3
commit 6b8c94a6e3
5 changed files with 19 additions and 37 deletions

View file

@ -2538,8 +2538,9 @@ bool skin_data_load(enum screen_type screen, struct wps_data *wps_data,
skin_buffer = wps_buffer;
wps_buffer = (char*)buf;
}
skin_buffer = ALIGN_UP(skin_buffer, 4); /* align on 4-byte boundary */
buffersize -= 3;
/* align to long */
ALIGN_BUFFER(skin_buffer, buffersize, sizeof(long));
#ifdef HAVE_BACKDROP_IMAGE
backdrop_filename = "-";
wps_data->backdrop_id = -1;