Skip to content

Commit 8d26aea

Browse files
committed
Check that fn are valid. Invoking invalid functions throws otherwise.
1 parent dcc5f5b commit 8d26aea

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: cores/esp8266/Schedule.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ static void recycle_fn_unsafe (scheduled_fn_t* fn)
6262
IRAM_ATTR // (not only) called from ISR
6363
bool schedule_function (const std::function<void(void)>& fn)
6464
{
65+
if (!fn)
66+
return false;
67+
6568
esp8266::InterruptLock lockAllInterruptsInThisScope;
6669

6770
scheduled_fn_t* item = get_fn_unsafe();
@@ -84,6 +87,9 @@ bool schedule_recurrent_function_us (const std::function<bool(void)>& fn, uint32
8487
{
8588
assert(repeat_us < decltype(recurrent_fn_t::callNow)::neverExpires); //~26800000us (26.8s)
8689

90+
if (!fn)
91+
return false;
92+
8793
esp8266::InterruptLock lockAllInterruptsInThisScope;
8894

8995
recurrent_fn_t* item = new (std::nothrow) recurrent_fn_t(repeat_us);

0 commit comments

Comments
 (0)