Skip to content

Commit

Permalink
Fix repaintable stack calculation (esp8266#5821)
Browse files Browse the repository at this point in the history
* Fix repaintable stack calculation

Fixes esp8266#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.
  • Loading branch information
earlephilhower authored and devyte committed Feb 27, 2019
1 parent 95cf925 commit 5632e81
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions cores/esp8266/cont_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 5632e81

Please sign in to comment.