diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 4faec0e63..2869baaa4 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -445,10 +445,12 @@ void CheckOther::invalidPointerCast() nextTok = nextTok->next(); toTok = tok->tokAt(2); } + if (!nextTok) + continue; if (toTok && toTok->str() == "const") toTok = toTok->next(); - if (!nextTok || !toTok || !toTok->isStandardType()) + if (!toTok || !toTok->isStandardType()) continue; // Find casted variable @@ -649,7 +651,7 @@ void CheckOther::checkRedundantAssignment() } } if (error) { - if (scope->type == Scope::eSwitch && Token::findmatch(it->second, "default|case", tok) && warning) + if (warning && scope->type == Scope::eSwitch && Token::findmatch(it->second, "default|case", tok)) redundantAssignmentInSwitchError(it->second, tok, tok->str()); else if (performance) { const bool nonlocal = nonLocal(it->second->variable());