Skip to content

Commit

Permalink
Lazy-allocate Base64/QuotedPrintable decoders in Rfc2047.DecodeToken()
Browse files Browse the repository at this point in the history
  • Loading branch information
jstedfast committed Aug 27, 2023
1 parent 155445e commit 19b73ba
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions MimeKit/Utils/Rfc2047.cs
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ static unsafe int DecodeToken (Token token, IMimeDecoder decoder, byte* input, b
static unsafe string DecodeTokens (ParserOptions options, List<Token> tokens, byte[] input, byte* inbuf, int length)
{
var decoded = new ValueStringBuilder (length);
var qp = new QuotedPrintableDecoder (true);
var base64 = new Base64Decoder ();
QuotedPrintableDecoder qp = null;
Base64Decoder base64 = null;
var output = new byte[length];
Token token;
int len;
Expand All @@ -480,10 +480,10 @@ static unsafe string DecodeTokens (ParserOptions options, List<Token> tokens, by
}

// base64 / quoted-printable decode each of the tokens...
if (encoding == ContentEncoding.Base64)
decoder = base64;
if (encoding == ContentEncoding.QuotedPrintable)
decoder = qp ??= new QuotedPrintableDecoder (true);
else
decoder = qp;
decoder = base64 ??= new Base64Decoder ();

outptr = outbuf;
outlen = 0;
Expand Down

0 comments on commit 19b73ba

Please sign in to comment.