Skip to content

Commit

Permalink
Handle null streams in catch for FetchStream/Async
Browse files Browse the repository at this point in the history
  • Loading branch information
jstedfast committed Jan 7, 2024
1 parent a6eb2fe commit 86c4c08
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions MailKit/Net/Imap/ImapFolderFetch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,7 @@ void FetchStream (ImapEngine engine, ImapCommand ic, int index)

stream.Position = 0;
} catch {
stream.Dispose ();
stream?.Dispose ();
throw;
} finally {
ArrayPool<byte>.Shared.Return (buf);
Expand All @@ -2067,7 +2067,7 @@ void FetchStream (ImapEngine engine, ImapCommand ic, int index)
ctx.Report (nread, size);
stream.Position = 0;
} catch {
stream.Dispose ();
stream?.Dispose ();
throw;
}
break;
Expand Down Expand Up @@ -2290,7 +2290,7 @@ async Task FetchStreamAsync (ImapEngine engine, ImapCommand ic, int index)

stream.Position = 0;
} catch {
stream.Dispose ();
stream?.Dispose ();
throw;
} finally {
ArrayPool<byte>.Shared.Return (buf);
Expand All @@ -2310,7 +2310,7 @@ async Task FetchStreamAsync (ImapEngine engine, ImapCommand ic, int index)
ctx.Report (nread, size);
stream.Position = 0;
} catch {
stream.Dispose ();
stream?.Dispose ();
throw;
}
break;
Expand Down

0 comments on commit 86c4c08

Please sign in to comment.