Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Comments

Fix invalid icon tests#21560

Merged
danmoseley merged 2 commits intodotnet:masterfrom
hughbe:fix-invalidicon-tests
Jun 27, 2017
Merged

Fix invalid icon tests#21560
danmoseley merged 2 commits intodotnet:masterfrom
hughbe:fix-invalidicon-tests

Conversation

@hughbe
Copy link

@hughbe hughbe commented Jun 26, 2017

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.


try
{
using (Icon icon = Icon.FromHandle(handle))
Copy link
Member

Choose a reason for hiding this comment

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

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Author

@hughbe hughbe Jun 27, 2017

Choose a reason for hiding this comment

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

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)

@danmoseley
Copy link
Member

Thanks @hughbe.

@danmoseley danmoseley merged commit eb98d9d into dotnet:master Jun 27, 2017
@hughbe hughbe deleted the fix-invalidicon-tests branch June 27, 2017 06:36
@karelz karelz modified the milestone: 2.1.0 Jun 29, 2017
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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants