Skip to content

Commit

Permalink
Fix EventHandlerDelegate crash (project-chip#9569)
Browse files Browse the repository at this point in the history
#### Problem

3a50501 project-chip#9366 caused a crash. In `AddEventHandlerDelegate()`,
`lDelegate` was accidentally a stack variable instead of a reference to
the caller-supplied storage.

This affects all platforms using LwIP.

#### Change overview

Add one small but important `&`.

Fixes project-chip#9563 _ESP32&ESP32C3 crash on system layer_

#### Testing

all-clusters-app on M5Stack
  • Loading branch information
kpschoedel committed Sep 9, 2021
1 parent 39e0604 commit d5cf34e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/system/SystemLayerImplLwIP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ CHIP_ERROR LayerImplLwIP::HandleSystemLayerEvent(Object & aTarget, EventType aEv

CHIP_ERROR LayerImplLwIP::AddEventHandlerDelegate(EventHandlerDelegate & aDelegate)
{
LwIPEventHandlerDelegate lDelegate = static_cast<LwIPEventHandlerDelegate &>(aDelegate);
LwIPEventHandlerDelegate & lDelegate = static_cast<LwIPEventHandlerDelegate &>(aDelegate);
VerifyOrReturnError(lDelegate.GetFunction() != nullptr, CHIP_ERROR_INVALID_ARGUMENT);
lDelegate.Prepend(mEventDelegateList);
return CHIP_NO_ERROR;
Expand Down

0 comments on commit d5cf34e

Please sign in to comment.