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

WI #2600 Fix NullReferenceException in Workspace.CollectDataLayoutNodes #2601

Merged
merged 1 commit into from
Dec 20, 2023

Conversation

efr15
Copy link
Contributor

@efr15 efr15 commented Dec 19, 2023

Fixes #2600

To reproduce the crash in a Cobol program: remove the . after IDENTIFICATION DIVISION

@efr15 efr15 requested a review from fm-117 December 19, 2023 12:58
@efr15 efr15 self-assigned this Dec 19, 2023
@efr15 efr15 linked an issue Dec 19, 2023 that may be closed by this pull request
@trafico-bot trafico-bot bot added the 🔍 Ready for Review Pull Request is not reviewed yet label Dec 19, 2023
@@ -1100,7 +1100,7 @@ static object GetEnd(long start, long length)
private List<Tuple<int, DataDefinition, int>> CollectDataLayoutNodes(CompilationUnit compilationUnit)
{
var dataLayoutNodes = new List<Tuple<int, DataDefinition, int>>();
Node dataDivision = compilationUnit.TemporaryProgramClassDocumentSnapshot.Root.MainProgram.GetChildren<DataDivision>().FirstOrDefault();
Node dataDivision = compilationUnit?.TemporaryProgramClassDocumentSnapshot?.Root?.MainProgram?.GetChildren<DataDivision>()?.FirstOrDefault();
Copy link
Contributor

Choose a reason for hiding this comment

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

compilationUnit, Root and the result of GetChildren<> cannot be null. TemporaryProgramClassDocumentSnapshot should not be null either as we force node rebuilding.

I'm ok to keep it like this safe approach but this will be changed if we move forward with the #nullable contexts.

@trafico-bot trafico-bot bot removed the 🔍 Ready for Review Pull Request is not reviewed yet label Dec 19, 2023
@efr15 efr15 merged commit 9eae24c into develop Dec 20, 2023
4 checks passed
@trafico-bot trafico-bot bot added the ✨ Merged Pull Request has been merged successfully label Dec 20, 2023
@fm-117 fm-117 mentioned this pull request Jan 2, 2024
@fm-117 fm-117 deleted the 2600-nullreferenceexception-in-datalayout branch June 10, 2024 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ Merged Pull Request has been merged successfully
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NullReferenceException in Workspace.CollectDataLayoutNodes
2 participants