diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index 315e66d57410..972772a7a202 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -410,10 +410,15 @@ const Token * CheckNullPointer::nullPointerByDeRefAndCheck(const Token *start, c } } else if (Token::simpleMatch(tok, "?") && Token::simpleMatch(tok->astOperand2(), ":")) { // ternary operator const Token *condTok = tok->astOperand1(); + const Token *colonTok = tok->astOperand2(); if (condTok->hasKnownIntValue() && !condTok->getKnownIntValue()) { /* Skip true branch */ - tok = tok->astOperand2(); + tok = colonTok; + } else { + /* Analyze true branch and skip the other branch */ + nullPointerByDeRefAndCheck(tok->next(), colonTok, printInconclusive); + tok = nextAfterAstRightmostLeaf(colonTok); } } else { if (isUnevaluated(tok)) {