Skip to content

Commit

Permalink
Fixed NullReferenceException that would occur if a client is Dispose(…
Browse files Browse the repository at this point in the history
…)d before a Connect() has succeeded.

This typically happens when using the using() construct:

  using (var pop3 = new Pop3Client())
  {
    pop3.Connect(...);  # Fails for some reason

  } # Throws a NullReferenceException here
  • Loading branch information
rix0rrr committed Feb 1, 2012
1 parent 77189a5 commit e79ac89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Pop3Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ internal override void OnLogin(string username, string password) {
}

internal override void OnLogout() {
SendCommand("QUIT");
if (_Stream != null)
{
SendCommand("QUIT");
}
}

internal override void CheckResultOK(string result) {
Expand Down
2 changes: 1 addition & 1 deletion TextClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public void Disconnect() {
_Stream.Dispose();
_Stream = null;
}
if (!_ReadThread.Join(2000)) {
if (_ReadThread != null && !_ReadThread.Join(2000)) {
_ReadThread.Abort();
}
}
Expand Down

0 comments on commit e79ac89

Please sign in to comment.