parent
9f81b48dc1
commit
22c1ce8a68
|
@ -1974,12 +1974,12 @@ void CheckOther::passedByValueError(const Token *tok, const std::string &parname
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
static bool isChar(const Variable* var)
|
static bool isChar(const Variable* var)
|
||||||
{
|
{
|
||||||
return(var && !var->isPointer() && !var->isArray() && (var->typeEndToken()->str() == "char" || var->typeEndToken()->previous()->str() == "char"));
|
return(var && !var->isPointer() && !var->isArray() && (var->typeEndToken()->str() == "char" || (var->typeEndToken()->previous() && var->typeEndToken()->previous()->str() == "char")));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isSignedChar(const Variable* var)
|
static bool isSignedChar(const Variable* var)
|
||||||
{
|
{
|
||||||
return(isChar(var) && !var->typeEndToken()->isUnsigned() && !var->typeEndToken()->previous()->isUnsigned());
|
return(isChar(var) && !var->typeEndToken()->isUnsigned() && (!var->typeEndToken()->previous() || !var->typeEndToken()->previous()->isUnsigned()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckOther::checkCharVariable()
|
void CheckOther::checkCharVariable()
|
||||||
|
|
|
@ -439,6 +439,9 @@ void ExecutionPath::checkScope(const Token *tok, std::list<ExecutionPath *> &che
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tok)
|
||||||
|
break;
|
||||||
|
|
||||||
// return/throw ends all execution paths
|
// return/throw ends all execution paths
|
||||||
if (tok->str() == "return" ||
|
if (tok->str() == "return" ||
|
||||||
tok->str() == "throw" ||
|
tok->str() == "throw" ||
|
||||||
|
|
|
@ -62,8 +62,9 @@ private:
|
||||||
TEST_CASE(nullpointerDelete);
|
TEST_CASE(nullpointerDelete);
|
||||||
TEST_CASE(nullpointerExit);
|
TEST_CASE(nullpointerExit);
|
||||||
TEST_CASE(nullpointerStdString);
|
TEST_CASE(nullpointerStdString);
|
||||||
|
|
||||||
TEST_CASE(functioncall);
|
TEST_CASE(functioncall);
|
||||||
|
|
||||||
|
TEST_CASE(crash1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void check(const char code[], bool inconclusive = false, bool cpp11 = false) {
|
void check(const char code[], bool inconclusive = false, bool cpp11 = false) {
|
||||||
|
@ -1873,6 +1874,12 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (error) Possible null pointer dereference: abc - otherwise it is redundant to check if abc is null at line 4\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (error) Possible null pointer dereference: abc - otherwise it is redundant to check if abc is null at line 4\n", errout.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void crash1() {
|
||||||
|
check("int f() {\n"
|
||||||
|
" return if\n"
|
||||||
|
"}");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestNullPointer)
|
REGISTER_TEST(TestNullPointer)
|
||||||
|
|
Loading…
Reference in New Issue