From 04e0c9f16b857d6fcff3b357d2d644132f4a7cf3 Mon Sep 17 00:00:00 2001 From: Daniel Svensson Date: Tue, 26 Jul 2022 13:25:29 +0200 Subject: [PATCH] Fix incorrect usage of ReadAtLeast Read as much as possible into the buffer without limiting to minimum count --- .../src/System/Xml/XmlBufferReader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBufferReader.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBufferReader.cs index fab4fb8531c1ca..0b8e923bdbc4b6 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBufferReader.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Xml/XmlBufferReader.cs @@ -231,7 +231,7 @@ private bool TryEnsureBytes(int count) } int needed = newOffsetMax - _offsetMax; DiagnosticUtility.DebugAssert(needed > 0, ""); - int read = _stream.ReadAtLeast(_buffer.AsSpan(_offsetMax, needed), needed, throwOnEndOfStream: false); + int read = _stream.ReadAtLeast(_buffer.AsSpan(_offsetMax), needed, throwOnEndOfStream: false); _offsetMax += read; if (read < needed)