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

Handle leak because FindClose is never called #12

Open
KirillOsenkov opened this issue Oct 18, 2021 · 2 comments
Open

Handle leak because FindClose is never called #12

KirillOsenkov opened this issue Oct 18, 2021 · 2 comments

Comments

@KirillOsenkov
Copy link
Contributor

I've debugged the handle leak in #11 and I've realized that FindClose is never called. If you place a breakpoint at this line it'll never get called:

retValue = NativeMethods.FindClose(handle);

The reason is at the time that function is called, IsClosed is already true, so it never enters the if statement body.

Not sure what's the best way to fix this, perhaps check for IsInvalid instead of IsClosed? Also calling SetHandleAsInvalid(); seemingly does nothing.

@JohnWintellect thanks again for the great tool, I use it daily.

@JohnWintellect
Copy link
Member

Hi Kirill!

Thanks for digging into this and it looks like that could be the issue. However, I have been retired for the last five years and no longer do any coding at all. :) Considering this is a program that runs only for a couple of seconds, is it really worth fixing? I guess causing cache flushing isn't so good.

Thanks for the kind words. It's so weird that a quick hack program I wrote on a plane is still in use.

Hope life is treating you well!

  • John

@KirillOsenkov
Copy link
Contributor Author

No worries at all, John, enjoy your well-deserved retirement! I myself am doing well and can't complain!

I agree this is not critical for a single-invocation tool. Certainly not worth coming out of retirement for ;)

If anyone else sees this, feel free to fork or maybe use my fork if you like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants