Parcourir la source

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

Fischer, Simon il y a 3 ans
Parent
commit
15cf3f2292
1 fichiers modifiés avec 2 ajouts et 1 suppressions
  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;