Skip to content

Commit

Permalink
Add some fiber null checks to teardownPlugins
Browse files Browse the repository at this point in the history
...before Fiber.state() is called and the program segfaults.
  • Loading branch information
zorael committed Feb 24, 2025
1 parent e94e59a commit 625bc7a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions source/kameloso/kameloso.d
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ public:
foreach (ref scheduledFiber; plugin.state.scheduledFibers)
{
// All fibers should be at HOLD state but be conservative
if (scheduledFiber.fiber.state != Fiber.State.EXEC)
if (scheduledFiber.fiber && (scheduledFiber.fiber.state != Fiber.State.EXEC))
{
destroy(scheduledFiber.fiber);
scheduledFiber.fiber = null;
Expand All @@ -668,12 +668,12 @@ public:

plugin.state.scheduledDelegates = null;

foreach (immutable type, ref fibersForType; plugin.state.awaitingFibers)
foreach (ref fibersForType; plugin.state.awaitingFibers)
{
foreach (ref fiber; fibersForType)
{
// As above
if (fiber.state != Fiber.State.EXEC)
if (fiber && (fiber.state != Fiber.State.EXEC))
{
destroy(fiber);
fiber = null;
Expand All @@ -683,7 +683,7 @@ public:

plugin.state.awaitingFibers = null;

foreach (immutable type, ref dgsForType; plugin.state.awaitingDelegates)
foreach (ref dgsForType; plugin.state.awaitingDelegates)
{
foreach (ref dg; dgsForType)
{
Expand Down

0 comments on commit 625bc7a

Please sign in to comment.