Handle Leak of CancellationTokenSource in RemoteJSRuntime class #59263
Labels
area-blazor
Includes: Blazor, Razor Components
feature-blazor-jsinterop
This issue is related to JSInterop in Blazor
help wanted
Up for grabs. We would accept a PR to help resolve this issue
Milestone
I analyzed the ASP .NET Core code using the Svace static analyzer. It has found a HANDLE_LEAK category error with the following message:
new CancellationTokenSource(TimeSpan.FromSeconds(10)) is not disposed at the end of the function
in method
TransmitStreamAsync()
. Here's the source code:aspnetcore/src/Components/Server/src/Circuits/RemoteJSRuntime.cs
Lines 153 to 174 in d088530
An instance of the
CancellationTokenSource
class is created and can be disposed of.When using CancellationTokenSource and CancellationToken objects, it is necessary to correctly organize the process of releasing them from memory.
What about rewriting the declaration of the
cancellationToken
by applying theusing
statement to theCancellationTokenSource
object as follows:Found by Linux Verification Center (linuxtesting.org) with SVACE.
Reporter: Aleksey Kolosov ([email protected]).
Organization: [email protected]
The text was updated successfully, but these errors were encountered: