Skip to content

Fix crash for finding symbols on bad paths #749

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

Merged
merged 2 commits into from
Sep 20, 2018

Conversation

rjmholt
Copy link
Contributor

@rjmholt rjmholt commented Sep 18, 2018

Fixes PowerShell/vscode-powershell#1518.

Protects against trying to open bad paths from ScriptFile.GetFile() in the symbol provider.

This fixes the given issue, but might not be the best way to do so -- perhaps better for GetFile() to return null in this case?

But we can change that at some later point perhaps.

@@ -346,9 +347,13 @@ public FindOccurrencesResult FindSymbolsInFile(ScriptFile scriptFile)
{
scriptFile = workspace.GetFile(file);
}
catch (IOException)
catch (Exception e) when (e is IOException
|| e is SecurityException
Copy link
Member

Choose a reason for hiding this comment

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

Does SecurityException include the "can't access due to permissions"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wow, I foolishly trusted that it did because the FileStream constructor docs only mention the exceptions I included here, but it looks like it doesn't >:(

Copy link
Member

@TylerLeonhardt TylerLeonhardt left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Collaborator

@SeeminglyScience SeeminglyScience left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@rkeithhill rkeithhill left a comment

Choose a reason for hiding this comment

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

LGTM

@rjmholt rjmholt merged commit 13f2107 into PowerShell:master Sep 20, 2018
@rjmholt rjmholt deleted the fix-auth-exception-crash branch December 12, 2018 06:01
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

Successfully merging this pull request may close these issues.

Powershell terminal randomly crashes with "Access to the Path e:\ is denied"
4 participants