From c0289719e71a91877c93e5c2d27e77fc56f7d148 Mon Sep 17 00:00:00 2001 From: John Colvin Date: Mon, 10 Oct 2022 14:17:41 -0400 Subject: [PATCH] fix (pre-emptive): Add null check in 'DisposeAll' fn Bugs (fixed): * The volsurface graph settings dialog crashes when you click OK/Apply Note: This fix is 'pre-emptive' because I saw the bug while working on the vs graph settings dialog. That feat will be added shortly in a subsequent commit (I wanted to commit the fix first so the bug wouldn't be in the official 'feat' revision/commit). Cause: A null ref ex is thrown in DisposeAll, because the List of IDisposables to dispose contains null items. Another way to fix the bug would have been to make sure null items aren't added to these Lists in the first place. However, that places the burden (to check for null) on the callers' shoulders, and leaves open the potential for this bug in every place where 'DisposeAll' is called. --- src/client/spark_core/Disposables/Disposable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/spark_core/Disposables/Disposable.cs b/src/client/spark_core/Disposables/Disposable.cs index b7eb78d69..4c488f126 100644 --- a/src/client/spark_core/Disposables/Disposable.cs +++ b/src/client/spark_core/Disposables/Disposable.cs @@ -63,7 +63,7 @@ namespace Spark.Core.Disposables { return; } foreach (var d in source) { - d.Dispose(); + d?.Dispose(); } if (clear) { source.Clear();