Skip to content

Commit 661b972

Browse files
committed
avoid 0 length array allocations
1 parent 567b3fe commit 661b972

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStaticMethods.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ static internal void AliasRegistryLookup(ref string host, ref string protocol)
100100
// If this logic changed, SNIPacketSetData needs to be changed as well
101101
internal static byte[] ObfuscatePassword(string password)
102102
{
103+
if (string.IsNullOrEmpty(password))
104+
{
105+
return Array.Empty<byte>();
106+
}
103107
byte[] bObfuscated = new byte[password.Length << 1];
104108
int s;
105109
byte bLo;
@@ -118,6 +122,10 @@ internal static byte[] ObfuscatePassword(string password)
118122

119123
internal static byte[] ObfuscatePassword(byte[] password)
120124
{
125+
if (password == null || password.Length == 0)
126+
{
127+
return Array.Empty<byte>();
128+
}
121129
byte bLo;
122130
byte bHi;
123131

0 commit comments

Comments
 (0)