Skip to content

Commit d54bb92

Browse files
committed
Align the buffer
1 parent dc136bf commit d54bb92

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

usermods/user_fx/user_fx.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ static uint16_t mode_diffusionfire(void) {
3535
}
3636

3737
if ((strip.now - SEGENV.step) >= refresh_ms) {
38-
uint16_t *tmp_row = (uint16_t *)(SEGMENT.data + SEGMENT.length());
38+
// Reserve one extra byte and align to 2-byte boundary to avoid hard-faults
39+
uint8_t *bufStart = SEGMENT.data + SEGMENT.length();
40+
uintptr_t aligned = (uintptr_t(bufStart) + 1u) & ~uintptr_t(0x1u);
41+
uint16_t *tmp_row = reinterpret_cast<uint16_t *>(aligned);
3942
SEGENV.step = strip.now;
4043
call++;
4144

0 commit comments

Comments
 (0)