Skip to content

Commit

Permalink
Merge pull request #1613 from jplag/bug/cpp-null-pointer
Browse files Browse the repository at this point in the history
Fixed a bug, where the cpp listener could throw a null pointer exception
  • Loading branch information
tsaglam authored Feb 26, 2024
2 parents 85b3736 + 8ad5794 commit cba2e06
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion languages/cpp/src/main/java/de/jplag/cpp/CPPListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ private void declarationRules() {

visit(ParameterDeclarationContext.class).map(VARDEF).withSemantics(CodeSemantics::new).onEnter((ctx, varReg) -> {
// don't register parameters in function declarations, e.g. bc6h_enc lines 117-120
if (hasAncestor(ctx, FunctionDefinitionContext.class, SimpleDeclarationContext.class)) {
if (hasAncestor(ctx, FunctionDefinitionContext.class, SimpleDeclarationContext.class) && ctx.declarator() != null) {
CPP14Parser.PointerDeclaratorContext pd = ctx.declarator().pointerDeclarator();
String name = pd.noPointerDeclarator().getText();
varReg.registerVariable(name, VariableScope.LOCAL, true);
Expand Down

0 comments on commit cba2e06

Please sign in to comment.