# HG changeset patch # User Michael Pavone # Date 1743054514 25200 # Node ID 596786e43c24ba2337563c5faf2e1c7f66c80222 # Parent 143cb5762ec904084d6b4bcd72c0a802bbd06dcd Avoid unaligned access in nk_murmur_hash diff -r 143cb5762ec9 -r 596786e43c24 nuklear_ui/nuklear.h --- a/nuklear_ui/nuklear.h Wed Mar 26 22:30:22 2025 -0700 +++ b/nuklear_ui/nuklear.h Wed Mar 26 22:48:34 2025 -0700 @@ -5560,7 +5560,6 @@ { /* 32-Bit MurmurHash3: https://code.google.com/p/smhasher/wiki/MurmurHash3*/ #define NK_ROTL(x,r) ((x) << (r) | ((x) >> (32 - r))) - union {const nk_uint *i; const nk_byte *b;} conv = {0}; const nk_byte *data = (const nk_byte*)key; const int nblocks = len/4; nk_uint h1 = seed; @@ -5573,10 +5572,8 @@ /* body */ if (!key) return 0; - conv.b = (data + nblocks*4); - blocks = (const nk_uint*)conv.i; - for (i = -nblocks; i; ++i) { - k1 = blocks[i]; + for (i = 0; i < nblocks*4; i+=4) { + k1 = data[i] | data[i+1] << 8u | data[i+2] << 16u | data[i+3] << 24u; k1 *= c1; k1 = NK_ROTL(k1,15); k1 *= c2;