From d2d8d2320bace3eb8b11c5c84c71804dd568a9e5 Mon Sep 17 00:00:00 2001 From: heartacker Date: Sun, 26 Apr 2026 12:29:18 +0800 Subject: [PATCH] fix: prevent NullReferenceException in CommandLog.AppendLine after completion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit 40765826c introduced CheckAccess() fast paths in AppendLine and Complete, breaking the execution ordering previously guaranteed by always dispatching to the UI thread. When Complete() runs on the UI thread it executes immediately and sets _builder = null, but AppendLine calls that were already queued from background threads (via HandleOutput) can still execute afterwards — hitting the null _builder. Guard AppendLine with a check for IsComplete or null _builder so queued invocations arriving after Complete() are silently dropped. --- src/ViewModels/CommandLog.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ViewModels/CommandLog.cs b/src/ViewModels/CommandLog.cs index f12d27b45..72ea149cb 100644 --- a/src/ViewModels/CommandLog.cs +++ b/src/ViewModels/CommandLog.cs @@ -62,6 +62,9 @@ public void AppendLine(string line = null) } else { + if (IsComplete || _builder == null) + return; + var newline = line ?? string.Empty; _builder.AppendLine(newline);