mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-16 18:25:11 -06:00
Use alignment-safe buffer handling
Casting a char* to a struct containing a uint32_t is not universally safe due to alignment constraints on reads on some platforms. Copy our possibly unaligned source data into an aligned area of memory to avoid SIGBUS on armhf. Reported by vorlonofportland in PR#403. This commit the John's optimized version of Vorlon's proposed fix.
This commit is contained in:
parent
4c87dd05ec
commit
d07f759ca3
@ -471,7 +471,9 @@ namespace IANAParser
|
||||
for(uint32_t index = 0; index < type_count; ++index)
|
||||
{
|
||||
fb_index = start_index + index * tzinfo_size;
|
||||
TTInfo info = *reinterpret_cast<TTInfo*>(&fileblock[fb_index]);
|
||||
/* Use memcpy instead of static_cast to avoid memory alignment issues with chars */
|
||||
TTInfo info{};
|
||||
memcpy(&info, &fileblock[fb_index], ttinfo_size);
|
||||
endian_swap(&info.gmtoff);
|
||||
tzinfo.push_back(
|
||||
{info, &fileblock[abbrev + info.abbrind],
|
||||
|
Loading…
Reference in New Issue
Block a user