Skip to content

Commit 65b80dc

Browse files
committed
Fixed MimeEntity.Dispose() to disconnect event handlers
1 parent 76e45ca commit 65b80dc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

MimeKit/MimeEntity.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,8 @@ void HeadersChanged (object sender, HeaderListChangedEventArgs e)
12881288
/// <see langword="false" /> to release only the unmanaged resources.</param>
12891289
protected virtual void Dispose (bool disposing)
12901290
{
1291+
ContentType.Changed -= ContentTypeChanged;
1292+
Headers.Changed -= HeadersChanged;
12911293
}
12921294

12931295
/// <summary>
@@ -1299,8 +1301,11 @@ protected virtual void Dispose (bool disposing)
12991301
/// the garbage collector can reclaim the memory that the <see cref="MimeEntity"/> was occupying.</remarks>
13001302
public void Dispose ()
13011303
{
1302-
Dispose (true);
1303-
IsDisposed = true;
1304+
if (!IsDisposed) {
1305+
Dispose (true);
1306+
IsDisposed = true;
1307+
}
1308+
13041309
GC.SuppressFinalize (this);
13051310
}
13061311

0 commit comments

Comments
 (0)