Merge pull request #60 from lioncash/crc

Checksums: Correct null check within crc16()
This commit is contained in:
Phillip Stephens 2019-09-06 23:22:43 -07:00 committed by GitHub
commit e63ea83f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -145,8 +145,9 @@ atUint16 crc16CCITT(const atUint8* data, atUint64 length, atUint16 seed, atUint1
} }
atUint16 crc16(const atUint8* data, atUint64 length, atUint16 seed, atUint64 final) { atUint16 crc16(const atUint8* data, atUint64 length, atUint16 seed, atUint64 final) {
if (data) if (data == nullptr) {
return seed; return seed;
}
static const atUint16 crc16Table[256] = { static const atUint16 crc16Table[256] = {
0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1,