name = name.Slice(index + 1);
}
- return name.ToString();
+ string result = name.ToString();
+ builder.Dispose();
+ return result;
}
}
if (index != -1)
{
// In the form of DOMAIN\User, cut off \User and return
- return name.Slice(0, index).ToString();
+ builder.Length = index;
+ return builder.ToString();
}
// In theory we should never get use out of LookupAccountNameW as the above API should
// Domain names aren't typically long.
// https://support.microsoft.com/en-us/help/909264/naming-conventions-in-active-directory-for-computers-domains-sites-and
Span<char> initialDomainNameBuffer = stackalloc char[64];
- var domainBuilder = new ValueStringBuilder(initialBuffer);
+ var domainBuilder = new ValueStringBuilder(initialDomainNameBuffer);
uint length = (uint)domainBuilder.Capacity;
// This API will fail to return the domain name without a buffer for the SID.
domainBuilder.EnsureCapacity((int)length);
}
+ builder.Dispose();
domainBuilder.Length = (int)length;
return domainBuilder.ToString();
}
builder.Length = (int)length;
// If we have a tilde in the path, make an attempt to expand 8.3 filenames
- return builder.AsSpan().Contains('~')
- ? PathHelper.TryExpandShortFileName(ref builder, null)
- : builder.ToString();
+ if (builder.AsSpan().Contains('~'))
+ {
+ string result = PathHelper.TryExpandShortFileName(ref builder, null);
+ builder.Dispose();
+ return result;
+ }
+
+ return builder.ToString();
}
set
{