@@ -801,7 +801,8 @@ void CheckMemoryLeakStructMember::checkStructVariable(const Variable* const vari
801
801
802
802
// Struct member is allocated => check if it is also properly deallocated..
803
803
else if ((assignToks = isMemberAssignment (tok2, variable->declarationId ())).first && assignToks.first ->varId ()) {
804
- if (getAllocationType (assignToks.second , assignToks.first ->varId ()) == AllocType::No)
804
+ const AllocType allocType = getAllocationType (assignToks.second , assignToks.first ->varId ());
805
+ if (allocType == AllocType::No)
805
806
continue ;
806
807
807
808
if (variable->isArgument () && variable->valueType () && variable->valueType ()->type == ValueType::UNKNOWN_TYPE && assignToks.first ->astParent ()) {
@@ -823,7 +824,7 @@ void CheckMemoryLeakStructMember::checkStructVariable(const Variable* const vari
823
824
824
825
else if (tok3->str () == " }" ) {
825
826
if (indentlevel3 == 0 ) {
826
- memoryLeak (tok3, variable->name () + " ." + tok2->strAt (2 ), Malloc );
827
+ memoryLeak (tok3, variable->name () + " ." + tok2->strAt (2 ), allocType );
827
828
break ;
828
829
}
829
830
--indentlevel3;
@@ -854,7 +855,7 @@ void CheckMemoryLeakStructMember::checkStructVariable(const Variable* const vari
854
855
// Deallocating the struct..
855
856
else if (Token::Match (tok3, " %name% ( %varid% )" , structid) && mSettings ->library .getDeallocFuncInfo (tok3)) {
856
857
if (indentlevel2 == 0 )
857
- memoryLeak (tok3, variable->name () + " ." + tok2->strAt (2 ), Malloc );
858
+ memoryLeak (tok3, variable->name () + " ." + tok2->strAt (2 ), allocType );
858
859
break ;
859
860
}
860
861
@@ -903,7 +904,7 @@ void CheckMemoryLeakStructMember::checkStructVariable(const Variable* const vari
903
904
!Token::Match (tok3, " return & %varid%" , structid) &&
904
905
!(Token::Match (tok3, " return %varid% . %var%" , structid) && tok3->tokAt (3 )->varId () == structmemberid) &&
905
906
!(Token::Match (tok3, " return %name% (" ) && tok3->astOperand1 () && deallocInFunction (tok3->astOperand1 (), structid))) {
906
- memoryLeak (tok3, variable->name () + " ." + tok2->strAt (2 ), Malloc );
907
+ memoryLeak (tok3, variable->name () + " ." + tok2->strAt (2 ), allocType );
907
908
}
908
909
break ;
909
910
}
0 commit comments