Skip to content

Commit

Permalink
make array rental return after TryReadPlpUnicodeChars unconditional (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Wraith2 committed Aug 15, 2023
1 parent 80905bd commit 359c4ba
Showing 1 changed file with 17 additions and 10 deletions.
Expand Up @@ -5683,18 +5683,20 @@ private bool TryReadSqlStringValue(SqlBuffer value, byte type, int length, Encod
{
char[] cc = null;
bool buffIsRented = false;
if (!TryReadPlpUnicodeChars(ref cc, 0, length >> 1, stateObj, out length, supportRentedBuff: true, rentedBuff: ref buffIsRented))
{
return false;
}
if (length > 0)
{
s = new string(cc, 0, length);
}
else
bool result = TryReadPlpUnicodeChars(ref cc, 0, length >> 1, stateObj, out length, supportRentedBuff: true, rentedBuff: ref buffIsRented);

if (result)
{
s = "";
if (length > 0)
{
s = new string(cc, 0, length);
}
else
{
s = "";
}
}

if (buffIsRented)
{
// do not use clearArray:true on the rented array because it can be massively larger
Expand All @@ -5705,6 +5707,11 @@ private bool TryReadSqlStringValue(SqlBuffer value, byte type, int length, Encod
ArrayPool<char>.Shared.Return(cc, clearArray: false);
cc = null;
}

if (!result)
{
return false;
}
}
else
{
Expand Down

0 comments on commit 359c4ba

Please sign in to comment.