From 15aae9a8a43301bbb66855590cac0e955815b5e0 Mon Sep 17 00:00:00 2001 From: Jonnern <10881387+Jonnern@users.noreply.github.com> Date: Wed, 20 Mar 2024 18:06:31 +0100 Subject: [PATCH] Fix memory leak in PreprocessStreamMessage (#105) --- Huobi.Net/Clients/SpotApi/HuobiSocketClientSpotApi.cs | 2 +- .../UsdtMarginSwapApi/HuobiSocketClientUsdtMarginSwapApi.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Huobi.Net/Clients/SpotApi/HuobiSocketClientSpotApi.cs b/Huobi.Net/Clients/SpotApi/HuobiSocketClientSpotApi.cs index 16fc8d60..8ac879d6 100644 --- a/Huobi.Net/Clients/SpotApi/HuobiSocketClientSpotApi.cs +++ b/Huobi.Net/Clients/SpotApi/HuobiSocketClientSpotApi.cs @@ -79,7 +79,7 @@ public override ReadOnlyMemory PreprocessStreamMessage(WebSocketMessageTyp if (type != WebSocketMessageType.Binary) return data; - var decompressedStream = new MemoryStream(); + using var decompressedStream = new MemoryStream(); using var deflateStream = new GZipStream(new MemoryStream(data.ToArray()), CompressionMode.Decompress); deflateStream.CopyTo(decompressedStream); decompressedStream.Position = 0; diff --git a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiSocketClientUsdtMarginSwapApi.cs b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiSocketClientUsdtMarginSwapApi.cs index be6d8e76..ffbba6ff 100644 --- a/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiSocketClientUsdtMarginSwapApi.cs +++ b/Huobi.Net/Clients/UsdtMarginSwapApi/HuobiSocketClientUsdtMarginSwapApi.cs @@ -46,7 +46,7 @@ public override ReadOnlyMemory PreprocessStreamMessage(WebSocketMessageTyp if (type != WebSocketMessageType.Binary) return data; - var decompressedStream = new MemoryStream(); + using var decompressedStream = new MemoryStream(); using var deflateStream = new GZipStream(new MemoryStream(data.ToArray()), CompressionMode.Decompress); deflateStream.CopyTo(decompressedStream); decompressedStream.Position = 0;