Skip to content

Commit

Permalink
Fix FP memleak (f'up to #12186)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Nov 16, 2023
1 parent f636f7f commit f943944
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/checkleakautovar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ void CheckLeakAutoVar::functionCall(const Token *tokName, const Token *tokOpenin
const Library::AllocFunc* deallocFunc = mSettings->library.getDeallocFuncInfo(tokName);
VarInfo::AllocInfo dealloc(deallocFunc ? deallocFunc->groupId : 0, VarInfo::DEALLOC, tokName);
if (const Library::AllocFunc* allocFunc = mSettings->library.getAllocFuncInfo(tokName)) {
if (allocFunc->arg == argNr) {
if (allocFunc->arg == argNr && !(arg->variable() && arg->variable()->isArgument() && arg->valueType() && arg->valueType()->pointer > 1)) {
leakIfAllocated(arg, varInfo);
VarInfo::AllocInfo& varAlloc = varInfo.alloctype[arg->varId()];
varAlloc.type = allocFunc->groupId;
Expand Down
4 changes: 4 additions & 0 deletions test/cfg/gnu.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,10 @@ void memleak_asprintf3() {
free(p);
}

void memleak_asprintf4(char** p) {
asprintf(p, "%s", "test");
}

void memleak_xmalloc()
{
char *p = (char*)xmalloc(10);
Expand Down

0 comments on commit f943944

Please sign in to comment.