Skip to content

Commit 1e36c26

Browse files
fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! fixup! Fix #11311 Do not search for null pointer in dead code
1 parent 13b2cab commit 1e36c26

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/checknullpointer.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -410,10 +410,15 @@ const Token * CheckNullPointer::nullPointerByDeRefAndCheck(const Token *start, c
410410
}
411411
} else if (Token::simpleMatch(tok, "?") && Token::simpleMatch(tok->astOperand2(), ":")) { // ternary operator
412412
const Token *condTok = tok->astOperand1();
413+
const Token *colonTok = tok->astOperand2();
413414

414415
if (condTok->hasKnownIntValue() && !condTok->getKnownIntValue()) {
415416
/* Skip true branch */
416-
tok = tok->astOperand2();
417+
tok = colonTok;
418+
} else {
419+
/* Analyze true branch and skip the other branch */
420+
nullPointerByDeRefAndCheck(tok->next(), colonTok, printInconclusive);
421+
tok = nextAfterAstRightmostLeaf(colonTok);
417422
}
418423
} else {
419424
if (isUnevaluated(tok)) {

0 commit comments

Comments
 (0)