Fixed false positive returnLocalVariable (#7180)
This commit is contained in:
parent
30f2bb7796
commit
23ad881c64
|
@ -117,7 +117,7 @@ bool CheckAutoVariables::isAutoVarArray(const Token *tok)
|
|||
return true;
|
||||
|
||||
// ValueFlow
|
||||
if (var->isPointer()) {
|
||||
if (var->isPointer() && !var->isArgument()) {
|
||||
for (std::list<ValueFlow::Value>::const_iterator it = tok->values.begin(); it != tok->values.end(); ++it) {
|
||||
const ValueFlow::Value &val = *it;
|
||||
if (val.tokvalue && isAutoVarArray(val.tokvalue))
|
||||
|
|
|
@ -636,6 +636,16 @@ private:
|
|||
" return str;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:7]: (error) Pointer to local array variable returned.\n", errout.str());
|
||||
|
||||
check("char * format_reg(char *outbuffer_start) {\n"
|
||||
" return outbuffer_start;\n"
|
||||
"}\n"
|
||||
"void print_with_operands() {\n"
|
||||
" char temp[42];\n"
|
||||
" char *tp = temp;\n"
|
||||
" tp = format_reg(tp);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void returnLocalVariable2() {
|
||||
|
|
Loading…
Reference in New Issue