Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixes for #3480 and #3568.

  • Loading branch information...
commit 22c1ce8a68de2c7311b6332eced6c1256edb8688 1 parent 9f81b48
PKEuS PKEuS authored
4 lib/checkother.cpp
View
@@ -1974,12 +1974,12 @@ void CheckOther::passedByValueError(const Token *tok, const std::string &parname
//---------------------------------------------------------------------------
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)
{
- 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()
3  lib/executionpath.cpp
View
@@ -439,6 +439,9 @@ void ExecutionPath::checkScope(const Token *tok, std::list<ExecutionPath *> &che
return;
}
+ if (!tok)
+ break;
+
// return/throw ends all execution paths
if (tok->str() == "return" ||
tok->str() == "throw" ||
9 test/testnullpointer.cpp
View
@@ -62,8 +62,9 @@ class TestNullPointer : public TestFixture {
TEST_CASE(nullpointerDelete);
TEST_CASE(nullpointerExit);
TEST_CASE(nullpointerStdString);
-
TEST_CASE(functioncall);
+
+ TEST_CASE(crash1);
}
void check(const char code[], bool inconclusive = false, bool cpp11 = false) {
@@ -1873,6 +1874,12 @@ class TestNullPointer : public TestFixture {
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)
Please sign in to comment.
Something went wrong with that request. Please try again.