Skip to content

Commit

Permalink
Fix memory leak when destroying ModeBase delegates (#28267)
Browse files Browse the repository at this point in the history
* Fixes #28265

* Fixed typo.
  • Loading branch information
hicklin authored Jul 26, 2023
1 parent b9de475 commit 1d49d9e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ void DishwasherMode::Shutdown()
}
if (gDishwasherModeDelegate != nullptr)
{
gDishwasherModeDelegate->~DishwasherModeDelegate();
delete gDishwasherModeDelegate;
gDishwasherModeDelegate = nullptr;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ void LaundryWasherMode::Shutdown()
}
if (gLaundryWasherModeDelegate != nullptr)
{
gLaundryWasherModeDelegate->~LaundryWasherModeDelegate();
delete gLaundryWasherModeDelegate;
gLaundryWasherModeDelegate = nullptr;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ void RvcRunMode::Shutdown()
}
if (gRvcRunModeDelegate != nullptr)
{
gRvcRunModeDelegate->~RvcRunModeDelegate();
delete gRvcRunModeDelegate;
gRvcRunModeDelegate = nullptr;
}
}

Expand Down Expand Up @@ -180,7 +181,8 @@ void RvcCleanMode::Shutdown()
}
if (gRvcCleanModeDelegate != nullptr)
{
gRvcCleanModeDelegate->~RvcCleanModeDelegate();
delete gRvcCleanModeDelegate;
gRvcCleanModeDelegate = nullptr;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ void RefrigeratorAndTemperatureControlledCabinetMode::Shutdown()
}
if (gTccModeDelegate != nullptr)
{
gTccModeDelegate->~TccModeDelegate();
delete gTccModeDelegate;
gTccModeDelegate = nullptr;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/clusters/mode-base-server/mode-base-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ class Delegate
// todo change once there is a clear public interface for the OnOff cluster data dependencies (#27508)
static IntrusiveList<Instance> gModeBaseAliasesInstances;

// This does not return a refernce to const IntrusiveList, because the caller might need
// This does not return a reference to const IntrusiveList, because the caller might need
// to change the state of the instances in the list and const IntrusiveList only allows
// access to const Instance.
IntrusiveList<Instance> & GetModeBaseInstanceList();
Expand Down

0 comments on commit 1d49d9e

Please sign in to comment.