Skip to content

Commit 4cf20e4

Browse files
authored
Fix NullReferenceException in Orphan() codepath
I ran into a `NullReferenceException` in this code path when locally debugging a function app in Visual Studio (source-linking brought me here). I don't know exactly what the side-effects of this null-ref are, but it seems wrong, especially since other parts of this method are correctly checking for a null `instance` method.
1 parent 9a3fbfe commit 4cf20e4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/WebJobs.Script.WebHost/WebJobsScriptHostService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ private bool ShutdownHostIfUnhealthy()
368368
/// <param name="instance">The <see cref="IHost"/> instance to remove</param>
369369
private async Task Orphan(IHost instance, ILogger logger, CancellationToken cancellationToken = default)
370370
{
371-
var scriptHost = (ScriptHost)instance.Services.GetService<ScriptHost>();
371+
var scriptHost = (ScriptHost)instance?.Services.GetService<ScriptHost>();
372372
if (scriptHost != null)
373373
{
374374
scriptHost.HostInitializing -= OnHostInitializing;

0 commit comments

Comments
 (0)