null pointers: Fixed false positive when 'do' are used
This commit is contained in:
parent
367efe31ea
commit
4e66dc105e
|
@ -1061,6 +1061,11 @@ void CheckOther::nullPointer()
|
|||
break;
|
||||
}
|
||||
|
||||
// Loop..
|
||||
/** @todo don't bail out if the variable is not used in the loop */
|
||||
else if (tok2->str() == "do")
|
||||
break;
|
||||
|
||||
// return at base level => stop checking
|
||||
else if (indentlevel2 == 0 && tok2->str() == "return")
|
||||
break;
|
||||
|
|
|
@ -512,7 +512,7 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// while..
|
||||
// loops..
|
||||
checkNullPointer("void freeAbc(struct ABC *abc)\n"
|
||||
"{\n"
|
||||
" while (abc)\n"
|
||||
|
@ -523,6 +523,19 @@ private:
|
|||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkNullPointer("void foo(struct ABC *abc)\n"
|
||||
"{\n"
|
||||
" int a = abc->a;"
|
||||
" do\n"
|
||||
" {\n"
|
||||
" if (abc)\n"
|
||||
" abc = abc->next;\n"
|
||||
" --a;\n"
|
||||
" }\n"
|
||||
" while (a > 0)\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// Dereferencing a pointer and then checking if it is null
|
||||
|
|
Loading…
Reference in New Issue