Skip to content

Commit

Permalink
Fix memory leak in EmbeddedResourceDecompressor.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
y0ung3r committed Apr 7, 2024
1 parent 00fa993 commit 556a28c
Showing 1 changed file with 1 addition and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ public sealed class EmbeddedResourceDecompressor : IResourceDecompressor
{
private readonly Assembly _assembly;

private static readonly Lazy<EmbeddedResourceDecompressor> InstanceFactory =
new Lazy<EmbeddedResourceDecompressor>(() => new EmbeddedResourceDecompressor());

public static EmbeddedResourceDecompressor Instance
=> InstanceFactory.Value;

public EmbeddedResourceDecompressor()
: this(Assembly.GetCallingAssembly())
{ }
Expand All @@ -39,7 +33,7 @@ private Stream GetResourceStream(string resourceName)

public XDocument Decompress(string resourceName)
{
var stream = GetResourceStream(resourceName);
using var stream = GetResourceStream(resourceName);
using var zip = new GZipStream(stream, CompressionMode.Decompress);
using var reader = new StreamReader(zip);

Expand Down

0 comments on commit 556a28c

Please sign in to comment.