Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/checkuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,8 @@ int CheckUninitVar::isFunctionParUsage(const Token *vartok, const Library& libra
const bool isnullbad = library.isnullargbad(start->previous(), argumentNumber + 1);
if (indirect == 0 && pointer && !address && isnullbad && alloc == NO_ALLOC)
return 1;
if (vartok->varId() == 0 && vartok->valueType())
indirect = vartok->valueType()->pointer;
bool hasIndirect = false;
const bool isuninitbad = library.isuninitargbad(start->previous(), argumentNumber + 1, indirect, &hasIndirect);
if (alloc != NO_ALLOC)
Expand Down
8 changes: 8 additions & 0 deletions test/testuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2173,6 +2173,14 @@ class TestUninitVar : public TestFixture {
" return p;\n"
"}\n");
ASSERT_EQUALS("", errout_str());

checkUninitVar("struct S { char c[10]; };\n" // #11290
"S* f() {\n"
" S* s = (S*)malloc(sizeof(S));\n"
" sprintf(s->c, \"abc\");\n"
" return s;\n"
"}\n");
ASSERT_EQUALS("", errout_str());
}

// class / struct..
Expand Down
Loading