Skip to content

Commit 3feb772

Browse files
Merge pull request #104 from scsd-cdh/fix/lfp_crc_clobber
Fixes LFP checksum not being computed properly when the destination overlaps with the source
2 parents 6506f1a + 7ec9523 commit 3feb772

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

MIDDLEWARE/LFP/lfp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ lfp_size_or_code_t lfp_encode(
8787
// Data segment
8888
lfp_cobs_encode_ctx_t encode_ctx;
8989
lfp_cobs_encode_init(&encode_ctx, p_data, length);
90+
const uint32_t crc32 = lfp_crc32(p_data, length);
9091
while (true) {
9192
const uint8_t chr = lfp_cobs_encode_next_byte(&encode_ctx);
9293
if (chr == 0xFF) break;
@@ -98,7 +99,6 @@ lfp_size_or_code_t lfp_encode(
9899
}
99100

100101
// Data checksum
101-
const uint32_t crc32 = lfp_crc32(p_data, length);
102102
WRITE_CHR(crc32 >> 25 & 0b01111111);
103103
WRITE_CHR(crc32 >> 18 & 0b01111111);
104104
WRITE_CHR(crc32 >> 11 & 0b01111111);

0 commit comments

Comments
 (0)