diff --git a/src/message.c b/src/message.c index d73fe75..e7c4a39 100644 --- a/src/message.c +++ b/src/message.c @@ -9,7 +9,8 @@ message_validate(const union Message* message) { if(message->header.crc != crc8(message, 3)) return MESSAGEERR_HEADERCRC; - if(message->header.crc != crc16(message, length - sizeof(struct Footer))) + struct Footer* footer = (void*)message + length - sizeof(struct Footer); + if(footer->crc != crc16(message, length - sizeof(struct Footer))) return MESSAGEERR_FOOTERCRC; return MESSAGEERR_NONE;