Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make array rental return after TryReadPlpUnicodeChars unconditional #2121

Merged
merged 1 commit into from Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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