This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Fix invalid icon tests#21560
Merged
danmoseley merged 2 commits intodotnet:masterfrom Jun 27, 2017
hughbe:fix-invalidicon-tests
Merged
Fix invalid icon tests#21560danmoseley merged 2 commits intodotnet:masterfrom hughbe:fix-invalidicon-tests
danmoseley merged 2 commits intodotnet:masterfrom
hughbe:fix-invalidicon-tests
Conversation
stephentoub
reviewed
Jun 26, 2017
|
|
||
| try | ||
| { | ||
| using (Icon icon = Icon.FromHandle(handle)) |
Member
There was a problem hiding this comment.
If it does happen to conflict with an existing handle, is this going to then potentially close that other handle causing problems for whatever code is using the other one?
Contributor
There was a problem hiding this comment.
Yes, I was going to point out the same thing. This seems like a very dangerous thing to do, even if any single collision is very unlikely.
I think we should just drop this kind of testing, and use a couple of "well-known" invalid handles, like 0 or 1.
Author
There was a problem hiding this comment.
Good point - I've updated the PR to use the handle 1 - IntPtr.Zero throws an exception all the time as it is special cased (we already have tests for that)
mellinoe
approved these changes
Jun 27, 2017
Member
|
Thanks @hughbe. |
picenka21
pushed a commit
to picenka21/runtime
that referenced
this pull request
Feb 18, 2022
* Fix invalid icon tests * Address PR feedback Commit migrated from dotnet/corefx@eb98d9d
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 #21360
Firstly, generate a random handle first - this gives us 4 billion different values of the handle instead of the 1 previously.
But if we're really unlucky, then keep going and repeat 100 times. Quite simply, if my analysis of the cause of the issue is correct, this should never fail.