1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Fix repaintable stack calculation (#5821)

* Fix repaintable stack calculation

Fixes #5794 as found by @mattbradford83

* Overwrite last word of stack as well

Under-by-one error would not reset the absolute end of the stack, adjust
comparison to fix.
This commit is contained in:
Earle F. Philhower, III 2019-02-27 01:37:42 +00:00 committed by Develo
parent 95cf925719
commit 5632e8156f

View File

@ -73,12 +73,10 @@ void cont_repaint_stack(cont_t *cont)
register uint32_t *sp asm("a1");
// Ensure 64 bytes adjacent to the current SP don't get touched to endure
// we don't accidentally trounce over locals or IRQ temps.
uint32_t sp_safe = CONT_STACKSIZE/4 - ((sp - &cont->stack[0] - 64)/4);
// Fill stack with magic values
for(uint32_t pos = 0; pos < sp_safe; pos++)
for ( uint32_t *pos = sp - 16; pos >= &cont->stack[0]; pos-- )
{
cont->stack[pos] = CONT_STACKGUARD;
*pos = CONT_STACKGUARD;
}
}