diff --git a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs index 4529cb57e..8922be4ce 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs @@ -73,9 +73,10 @@ public async Task ReadAsync(Stream input, CancellationToken cancella bufferedStream.Position = 0; } - var reader = new StreamReader(bufferedStream); - - return await new OpenApiTextReaderReader(_settings).ReadAsync(reader, cancellationToken); + using (var reader = new StreamReader(bufferedStream)) + { + return await new OpenApiTextReaderReader(_settings).ReadAsync(reader, cancellationToken); + } } ///