Skip to content

Commit

Permalink
Fix issue 9348: FP uninitvar for pointer passed to memcpy (danmar#2167)
Browse files Browse the repository at this point in the history
  • Loading branch information
pfultz2 authored and jubnzv committed Nov 13, 2019
1 parent 7c6a29d commit 6fa0716
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
11 changes: 11 additions & 0 deletions test/testuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4448,6 +4448,17 @@ class TestUninitVar : public TestFixture {
" 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() {
Expand Down

0 comments on commit 6fa0716

Please sign in to comment.