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
3 changes: 2 additions & 1 deletion lib/checkleakautovar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,10 @@ bool CheckLeakAutoVar::checkScope(const Token * const startToken,
// check for function call
const Token * const openingPar = isFunctionCall(innerTok);
if (openingPar) {
const Library::AllocFunc* allocFunc = mSettings->library.getDeallocFuncInfo(innerTok);
// innerTok is a function name
const VarInfo::AllocInfo allocation(0, VarInfo::NOALLOC);
functionCall(innerTok, openingPar, varInfo, allocation, nullptr);
functionCall(innerTok, openingPar, varInfo, allocation, allocFunc);
innerTok = openingPar->link();
}
}
Expand Down
30 changes: 30 additions & 0 deletions test/cfg/posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,36 @@ void * identicalCondition_mmap(int fd, size_t size) // #9940
return buffer;
}

int munmap_no_double_free(int tofd, // #11396
int fromfd,
size_t len)
{
int rc;
void* fptr = mmap(NULL,len,PROT_READ|PROT_WRITE,MAP_SHARED,fromfd,(off_t)0);
if (fptr == MAP_FAILED) {
return -1;
}

void* tptr = mmap(NULL,len,PROT_READ|PROT_WRITE,MAP_SHARED,tofd,(off_t)0);
if (tptr == MAP_FAILED) {
// cppcheck-suppress memleak
return -1;
}

memcpy(tptr,fptr,len);

if ((rc = munmap(fptr,len)) != 0) {
// cppcheck-suppress memleak
return -1;
}

if ((rc = munmap(tptr,len)) != 0) {
return -1;
}

return rc;
}

void resourceLeak_fdopen(int fd)
{
// cppcheck-suppress unreadVariable
Expand Down