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 GetKnownHttpScheme "safe" #21204

Merged
merged 3 commits into from
Apr 28, 2020
Merged

Conversation

benaadams
Copy link
Member

To @blowdart with ❤

Contributes to #4720

{
fixed (byte* data = span)
if (span.Length >= sizeof(ulong))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JIT isn't always smart enough to match this manual check to the call to BinaryPrimitives below, so it could end up duplicating the bounds check. Suggest using BinaryPrimitives.TryReadUInt64LittleEndian instead, which guarantees that the bounds check will be emitted a maximum of once.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raised issue for it dotnet/runtime#35348; will try the the Try version as you suggest

@halter73 halter73 merged commit 8b2f808 into dotnet:master Apr 28, 2020
@halter73
Copy link
Member

Thanks!

@benaadams benaadams deleted the GetKnownHttpScheme branch May 27, 2020 06:47
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants