-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[Json] Fix error case in HalfConverter when dealing with large values #116884
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an error encountered when deserializing large Half values by adjusting the buffer length validations and adding comprehensive tests for various numeric types.
- Updated the HalfConverter to use a new constant for unescaped format length checks.
- Added new theory tests in NumberHandlingTests to validate error handling for large values across multiple numeric types.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
src/libraries/System.Text.Json/tests/Common/NumberHandlingTests.cs | Added tests to verify proper exception throwing for oversized values during deserialization. |
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/HalfConverter.cs | Modified the logic in TryGetFloatingPointConstant to properly check the value length for both escaped and unescaped constants. |
...raries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/HalfConverter.cs
Outdated
Show resolved
Hide resolved
Tagging subscribers to this area: @dotnet/area-system-text-json, @gregsdennis |
...raries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/HalfConverter.cs
Show resolved
Hide resolved
/azp run |
You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list. |
/azp run all |
No pipelines are associated with this pull request. |
/azp run runtime |
Azure Pipelines successfully started running 1 pipeline(s). |
When deserializing
Half
, sending a large value like123456789012345678901
would result inArgumentException: Destination is too short.