Skip to content
Merged
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: 1 addition & 1 deletion cfg/posix.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5237,7 +5237,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<arg nr="2" direction="inout">
<not-null/>
</arg>
<arg nr="3" direction="in">
<arg nr="3" direction="inout">
<not-null/>
<not-uninit/>
</arg>
Expand Down
3 changes: 2 additions & 1 deletion lib/checkleakautovar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,8 @@ void CheckLeakAutoVar::functionCall(const Token *tokName, const Token *tokOpenin
while (Token::Match(arg, "%name% .|:: %name%"))
arg = arg->tokAt(2);

if (Token::Match(arg, "%var% [-,)] !!.") || Token::Match(arg, "& %var% !!.")) {
if ((Token::Match(arg, "%var% [-,)] !!.") && !(arg->variable() && arg->variable()->isArray())) ||
(Token::Match(arg, "& %var% !!.") && !(arg->next()->variable() && arg->next()->variable()->isArray()))) {
// goto variable
const bool isAddressOf = arg->str() == "&";
if (isAddressOf)
Expand Down
9 changes: 9 additions & 0 deletions test/cfg/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,15 @@ void memleak_getline() { // #11043
line = NULL;
}

void memleak_getline_array(FILE* stream) { // #12498
char* a[2] = { 0 };
size_t n;
getline(&a[0], &n, stream);
getline(&a[1], &n, stream);
free(a[0]);
free(a[1]);
}

void * identicalCondition_mmap(int fd, size_t size) // #9940
{
void* buffer = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
Expand Down