Fix issue 9348: FP uninitvar for pointer passed to memcpy (#2167)

This commit is contained in:
Paul Fultz II 2019-09-10 12:40:08 -05:00 committed by Daniel Marjamäki
parent ddb1f1b5ce
commit 2595b82634
2 changed files with 12 additions and 1 deletions

View File

@ -1051,7 +1051,7 @@ bool isVariableChangedByFunctionCall(const Token *tok, int indirect, const Setti
argDirection == Library::ArgumentChecks::Direction::DIR_INOUT) {
// With out or inout the direction of the content is specified, not a pointer itself, so ignore pointers for now
const ValueType * const valueType = tok1->valueType();
if (valueType && !valueType->pointer) {
if (valueType && valueType->pointer == indirect) {
return true;
}
}

View File

@ -4448,6 +4448,17 @@ private:
" return;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// # 9348
valueFlowUninit("void f(int *a) {\n"
" int b = 0;\n"
" memcpy(a, &b, sizeof(b));\n"
"}\n"
"void g() {\n"
" int i;\n"
" f(&i);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void uninitvar_memberfunction() {