diff options
author | Jeff Johnston | 2019-12-04 20:59:36 +0000 |
---|---|---|
committer | Jeff Johnston | 2019-12-05 15:59:43 +0000 |
commit | 45585fcbbf9e051d76afdd3a96374cc394f624e5 (patch) | |
tree | 17783ac4c71459f2b9057231931e0fc020a153d7 | |
parent | 9d897fcc04f39fe62ca1e5935d341e0a4b60f30d (diff) | |
download | org.eclipse.cdt-45585fcbbf9e051d76afdd3a96374cc394f624e5.tar.gz org.eclipse.cdt-45585fcbbf9e051d76afdd3a96374cc394f624e5.tar.xz org.eclipse.cdt-45585fcbbf9e051d76afdd3a96374cc394f624e5.zip |
Bug 553761 - NPE at GNUCSourceParser.identifier
- add null node check in GNUSourceParser.identifier()
- same for GNUCPPSourceParser.buildName()
Change-Id: Ic170d0220d179947af5b9c0d7dc50f1ed9e5965d
2 files changed, 9 insertions, 4 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java index 88e1f9afc7a..77e2f6da450 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2015 IBM Corporation and others. + * Copyright (c) 2005, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import org.eclipse.cdt.core.dom.ast.ASTCompletionNode; import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier; @@ -1748,7 +1749,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser { consume(); n = getNodeFactory().newName(t.getCharImage()); setRange(n, t.getOffset(), t.getEndOffset()); - createCompletionNode(t).addName(n); + ASTCompletionNode node = createCompletionNode(t); + if (node != null) + node.addName(n); return n; default: diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java index ebdf710df1d..860cd7d20d0 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2016 IBM Corporation and others. + * Copyright (c) 2002, 2019 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -462,7 +462,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser { switch (nt.getType()) { case IToken.tEOC: case IToken.tCOMPLETION: - createCompletionNode(nt).addName(name); + ASTCompletionNode node = createCompletionNode(nt); + if (node != null) + node.addName(name); break; } return name; |