@@ -1072,9 +1072,8 @@ void CheckLeakAutoVarImpl::changeAllocStatus(VarInfo &varInfo, const VarInfo::Al
10721072
10731073void CheckLeakAutoVarImpl::functionCall (const Token *tokName, const Token *tokOpeningPar, VarInfo &varInfo, const VarInfo::AllocInfo& allocation, const Library::AllocFunc* af)
10741074{
1075- // Ignore function call?
1076- const bool isLeakIgnore = mSettings .library .isLeakIgnore (mSettings .library .getFunctionName (tokName));
1077- if (mSettings .library .getReallocFuncInfo (tokName))
1075+ const bool isLeakIgnore = tokName ? mSettings .library .isLeakIgnore (mSettings .library .getFunctionName (tokName)) : false ;
1076+ if (tokName && mSettings .library .getReallocFuncInfo (tokName))
10781077 return ;
10791078 if (tokName && tokName->next ()->valueType () && tokName->next ()->valueType ()->container && tokName->next ()->valueType ()->container ->stdStringLike )
10801079 return ;
@@ -1125,26 +1124,30 @@ void CheckLeakAutoVarImpl::functionCall(const Token *tokName, const Token *tokOp
11251124
11261125 // Is variable allocated?
11271126 if (!isnull && (!af || af->arg == argNr)) {
1128- const Library::AllocFunc* deallocFunc = mSettings .library .getDeallocFuncInfo (tokName);
1127+ const Library::AllocFunc* deallocFunc = tokName ? mSettings .library .getDeallocFuncInfo (tokName) : nullptr ;
11291128 VarInfo::AllocInfo dealloc (deallocFunc ? deallocFunc->groupId : 0 , VarInfo::DEALLOC , tokName);
1130- if (const Library::AllocFunc* allocFunc = mSettings .library .getAllocFuncInfo (tokName)) {
1131- if (mSettings .library .getDeallocFuncInfo (tokName)) {
1132- changeAllocStatus (varInfo, dealloc.type == 0 ? allocation : dealloc, tokName, arg);
1133- }
1134- if (allocFunc->arg == argNr &&
1135- !(arg->variable () && arg->variable ()->isArgument () && arg->valueType () && arg->valueType ()->pointer > 1 ) &&
1136- (isAddressOf || (arg->valueType () && arg->valueType ()->pointer == 2 ))) {
1137- leakIfAllocated (arg, varInfo);
1138- VarInfo::AllocInfo& varAlloc = varInfo.alloctype [arg->varId ()];
1139- varAlloc.type = allocFunc->groupId ;
1140- varAlloc.status = VarInfo::ALLOC ;
1141- varAlloc.allocTok = arg;
1129+ if (tokName) {
1130+ if (const Library::AllocFunc* allocFunc = mSettings .library .getAllocFuncInfo (tokName)) {
1131+ if (mSettings .library .getDeallocFuncInfo (tokName)) {
1132+ changeAllocStatus (varInfo, dealloc.type == 0 ? allocation : dealloc, tokName, arg);
1133+ }
1134+ if (allocFunc->arg == argNr &&
1135+ !(arg->variable () && arg->variable ()->isArgument () && arg->valueType () && arg->valueType ()->pointer > 1 ) &&
1136+ (isAddressOf || (arg->valueType () && arg->valueType ()->pointer == 2 ))) {
1137+ leakIfAllocated (arg, varInfo);
1138+ VarInfo::AllocInfo& varAlloc = varInfo.alloctype [arg->varId ()];
1139+ varAlloc.type = allocFunc->groupId ;
1140+ varAlloc.status = VarInfo::ALLOC ;
1141+ varAlloc.allocTok = arg;
1142+ }
11421143 }
1144+ else if (isLeakIgnore)
1145+ checkTokenInsideExpression (arg, varInfo);
1146+ else
1147+ changeAllocStatus (varInfo, dealloc.type == 0 ? allocation : dealloc, tokName, arg);
1148+ } else {
1149+ changeAllocStatus (varInfo, allocation, nullptr , arg);
11431150 }
1144- else if (isLeakIgnore)
1145- checkTokenInsideExpression (arg, varInfo);
1146- else
1147- changeAllocStatus (varInfo, dealloc.type == 0 ? allocation : dealloc, tokName, arg);
11481151 }
11491152 }
11501153 // Check smart pointer
0 commit comments