From df4b9627b2e2beaeca5a7892218b63461e29a50f Mon Sep 17 00:00:00 2001 From: Wraith2 Date: Thu, 8 Jan 2026 21:20:41 +0000 Subject: [PATCH] ensure that 0 length reads return an empty array not null --- .../src/Microsoft/Data/SqlClient/TdsParserStateObject.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs index bba4808efd..c8aa34ed54 100644 --- a/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs +++ b/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs @@ -2356,9 +2356,10 @@ internal TdsOperationStatus TryReadPlpBytes(ref byte[] buff, int offset, int len { // if there is a snapshot which it contains a stored plp buffer take it // and try to use it if it is the right length - buff = TryTakeSnapshotStorage() as byte[]; - if (buff != null) + byte[] existingBuff = TryTakeSnapshotStorage() as byte[]; + if (existingBuff != null) { + buff = existingBuff; totalBytesRead = _snapshot.GetPacketDataOffset(); } }