Repository navigation
Fix System.OverflowException in WindowChromeWorker._HandleNCHitTest - #6779
Merged
dipeshmsft merged 2 commits intoDec 14, 2022
Merged
Conversation
The lParam may be the int 64 value which will throw OverflowException when cast to int 32. We only use the int32 part inside the int64, so it's safe for us to use ToInt64 first and then cast to int32. See dotnet#6777
Contributor
|
The comments are not very useful on their own. If you want to include any, it would be better to say what's going on, like "// avoid overflow for negative coordinates (#6777)". Otherwise looks good to me. |
Member
Author
|
Thank you @miloush and I fixed it. |
anjaligupta-dev
approved these changes
Sep 12, 2022
Member
Member
Author
|
Thank you @dipeshmsft |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6777
Description
The lParam may be the int 64 value which will throw OverflowException when cast to int 32. We only use the int32 part inside the int64, so it's safe for us to use ToInt64 first and then cast to int32.
And I think this fix is safe. Because the
HandleWmNcHitTestMsgwhich handle theNCHitTestwill call theNativeMethods.SignedLOWORDmethod. TheSignedLOWORDwill cast to long then cast to int32.wpf/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/NativeMethodsCLR.cs
Lines 6208 to 6210 in 7add0fc
Customer Impact
See #6777
Regression
None.
Testing
Just the CI.
And I pick the code to dotnet-campus/DotNetCampus.CustomWpf#20 and I build the private version to test this by my application.
Risk
Low. It is safe for us to use IntPtr.ToInt64 and cast the long to int.
Microsoft Reviewers: Open in CodeFlow