Skip to content

Commit

Permalink
[c/c++] NPE Due to Incorrect Order of Statements (joernio#3878)
Browse files Browse the repository at this point in the history
The statements in the matcher statement first check `other.getParent != null` before checking `other != null`.

This has led to some NPE errors, reported by the community on Discord.
  • Loading branch information
DavidBakerEffendi authored Dec 3, 2023
1 parent b84fb87 commit 7d96deb
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object AstCreatorHelper {

trait AstCreatorHelper(implicit withSchemaValidation: ValidationMode) { this: AstCreator =>

import io.joern.c2cpg.astcreation.AstCreatorHelper._
import io.joern.c2cpg.astcreation.AstCreatorHelper.*

private var usedVariablePostfix: Int = 0

Expand Down Expand Up @@ -340,12 +340,12 @@ trait AstCreatorHelper(implicit withSchemaValidation: ValidationMode) { this: As
s"${fullName(f.getParent)}.${shortName(f)}"
case e: IASTElaboratedTypeSpecifier =>
s"${fullName(e.getParent)}.${ASTStringUtil.getSimpleName(e.getName)}"
case d: IASTIdExpression => ASTStringUtil.getSimpleName(d.getName)
case _: IASTTranslationUnit => ""
case u: IASTUnaryExpression => code(u.getOperand)
case other if other.getParent != null => fullName(other.getParent)
case other if other != null => notHandledYet(other); ""
case null => ""
case d: IASTIdExpression => ASTStringUtil.getSimpleName(d.getName)
case _: IASTTranslationUnit => ""
case u: IASTUnaryExpression => code(u.getOperand)
case other if other != null && other.getParent != null => fullName(other.getParent)
case other if other != null => notHandledYet(other); ""
case null => ""
}
fixQualifiedName(qualifiedName).stripPrefix(".")
}
Expand Down

0 comments on commit 7d96deb

Please sign in to comment.