Quantcast
Channel: SSH.NET Library
Viewing all articles
Browse latest Browse all 2955

Created Unassigned: SshCommand doesn't cleanup subscribed events [2295]

$
0
0
The SshCommand class leaves the unerlying channel subscribed to the session events after running a command.

Repro is:
```
using (var client = new SshClient(connectionInfo))
{
client.Connect();

for (var i = 0; i < 100; ++i)
{
// Inspect client.Session.ErrorOccured.GetInvocationList()
using (var cmd = client.CreateCommand("echo hi"))
{
cmd.Execute();
}
// Inspect client.Session.ErrorOccured.GetInvocationList()
// Invocation list is one greater than before.
}
var after = GetEventCount(client);
Assert.AreEqual(before, after);
}
```

It looks like the bug is in SshCommand.EndExecute where this._channel is set to null without being disposed. A proposed fix is attached.

Viewing all articles
Browse latest Browse all 2955

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>