Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2013-08-28 16:51:59 -0400
committerSergey Prigogin2013-08-28 16:51:59 -0400
commitaf5a14ac6d1512d8174de907019d58f99c00a536 (patch)
tree3c975617080bce856f1785cd4e20de811c149015 /codan/org.eclipse.cdt.codan.checkers
parent3e0f5e9e44f4dbf2b04cb57bff01cc5f9de2713a (diff)
downloadorg.eclipse.cdt-af5a14ac6d1512d8174de907019d58f99c00a536.tar.gz
org.eclipse.cdt-af5a14ac6d1512d8174de907019d58f99c00a536.tar.xz
org.eclipse.cdt-af5a14ac6d1512d8174de907019d58f99c00a536.zip
Bug 390782 - NPE in AssignmentToItselfChecker$1.isAssignmentToItself
Diffstat (limited to 'codan/org.eclipse.cdt.codan.checkers')
-rw-r--r--codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentToItselfChecker.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentToItselfChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentToItselfChecker.java
index f216659e03..cbf50c72ac 100644
--- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentToItselfChecker.java
+++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/AssignmentToItselfChecker.java
@@ -41,16 +41,20 @@ public class AssignmentToItselfChecker extends AbstractIndexAstChecker {
return PROCESS_CONTINUE;
}
- private boolean isAssignmentToItself(IASTExpression e) {
- if (e instanceof IASTBinaryExpression) {
- IASTBinaryExpression binExpr = (IASTBinaryExpression) e;
+ private boolean isAssignmentToItself(IASTExpression expr) {
+ if (expr instanceof IASTBinaryExpression) {
+ IASTBinaryExpression binExpr = (IASTBinaryExpression) expr;
if (binExpr.getOperator() == IASTBinaryExpression.op_assign) {
- String op1 = binExpr.getOperand1().getRawSignature();
- String op2 = binExpr.getOperand2().getRawSignature();
- String expr = binExpr.getRawSignature();
- return op1.equals(op2)
- // When macro is used, RawSignature returns macro name, see bug 321933
- && !op1.equals(expr);
+ IASTExpression operand1 = binExpr.getOperand1();
+ IASTExpression operand2 = binExpr.getOperand2();
+ if (operand1 != null && operand2 != null) {
+ String op1 = operand1.getRawSignature();
+ String op2 = operand2.getRawSignature();
+ String exprImage = binExpr.getRawSignature();
+ return op1.equals(op2)
+ // When macro is used, RawSignature returns macro name, see bug 321933
+ && !op1.equals(exprImage);
+ }
}
}
return false;

Back to the top