# HG changeset patch # User heydowns # Date 1244772792 0 # Node ID 63e3c82b92d984875e4e12266ff118cff41e5f26 # Parent ba8654776eab758604ea4eb8644fb360d2fb0d83 Fix cast of byte buffer to uint32 that was disregarding alignment requirements. Now calculates crc byte at a time until aligned, then continues with uint32 optimized calculation. This fixes crashes during mlp decoding on sparc (at least, maybe others). diff -r ba8654776eab -r 63e3c82b92d9 crc.c --- a/crc.c Thu Jun 11 10:16:51 2009 +0000 +++ b/crc.c Fri Jun 12 02:13:12 2009 +0000 @@ -115,7 +115,10 @@ const uint8_t *end= buffer+length; #if !CONFIG_SMALL - if(!ctx[256]) + if(!ctx[256]) { + while(((intptr_t) buffer & 3) && buffer < end) + crc = ctx[((uint8_t)crc) ^ *buffer++] ^ (crc >> 8); + while(buffer>16)&0xFF)] ^ctx[0*256 + ((crc>>24) )]; } + } #endif while(buffer> 8);