From 4830126cf0b43b252bf3cc57b86d15a2e3663f9b Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Wed, 26 Jul 2023 11:19:48 -0400 Subject: [PATCH] Fix erroneous double list allocation in JsonWebToken.Audiences --- src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs index 8885a8addb..e9b15adab1 100644 --- a/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs +++ b/src/Microsoft.IdentityModel.JsonWebTokens/JsonWebToken.cs @@ -605,9 +605,10 @@ public IEnumerable Audiences if (Payload.TryGetValue(JwtRegisteredClaimNames.Aud, out JsonElement audiences)) { if (audiences.ValueKind == JsonValueKind.String) - _audiences = new List { audiences.GetString() }; - - if (audiences.ValueKind == JsonValueKind.Array) + { + _audiences.Add(audiences.GetString()); + } + else if (audiences.ValueKind == JsonValueKind.Array) { foreach (JsonElement jsonElement in audiences.EnumerateArray()) _audiences.Add(jsonElement.ToString());