Ver Fonte

add somewhat explicit uint8_t cast to crc computation to avoid errors caused by signedness mistakes

Fischer, Simon há 3 anos atrás
pai
commit
15cf3f2292
1 ficheiros alterados com 2 adições e 1 exclusões
  1. 2 1
      src/shellmatta_crc.c

+ 2 - 1
src/shellmatta_crc.c

@@ -125,7 +125,8 @@ uint32_t crc32Fast(char* data, uint16_t size, uint32_t* lookupTable)
 
     for (i = 0; i < size; i++)
     {
-        crcTemp = lookupTable[data[i] ^ (crcTemp & 0xff)] ^ (crcTemp >> 8);
+        uint8_t index = data[i] ^ (crcTemp & 0xff);
+        crcTemp = lookupTable[index] ^ (crcTemp >> 8);
     }
 
     return ~crcTemp;