@@ -514,7 +514,7 @@ void CheckBufferOverrun::parse_for_body(const Token *tok2, const ArrayInfo &arra
514514
515515
516516
517- void CheckBufferOverrun::checkFunctionParameter (const Token &tok, unsigned int par, const ArrayInfo &arrayInfo, std::list<std::string> functionNames )
517+ void CheckBufferOverrun::checkFunctionParameter (const Token &tok, unsigned int par, const ArrayInfo &arrayInfo)
518518{
519519 // total_size : which parameter in function call takes the total size?
520520 std::map<std::string, unsigned int > total_size;
@@ -677,31 +677,21 @@ void CheckBufferOverrun::checkFunctionParameter(const Token &tok, unsigned int p
677677 }
678678 }
679679 }
680-
681- // Calling function..
682- if (Token::Match (ftok, " %var% (" )) {
683- ArrayInfo ai (arrayInfo);
684- ai.varid (parameterVarId);
685- checkFunctionCall (ftok, ai, functionNames);
686- }
687680 }
688681 }
689682 }
690683}
691684
692685
693- void CheckBufferOverrun::checkFunctionCall (const Token *tok, const ArrayInfo &arrayInfo, std::list<std::string> functionNames )
686+ void CheckBufferOverrun::checkFunctionCall (const Token *tok, const ArrayInfo &arrayInfo)
694687{
695- if (std::find (functionNames.begin (), functionNames.end (), tok->str ()) != functionNames.end ())
696- return ;
697- functionNames.push_back (tok->str ());
698688
699689 // 1st parameter..
700690 if (Token::Match (tok->tokAt (2 ), " %varid% ,|)" , arrayInfo.varid ()))
701- checkFunctionParameter (*tok, 1 , arrayInfo, functionNames );
691+ checkFunctionParameter (*tok, 1 , arrayInfo);
702692 else if (Token::Match (tok->tokAt (2 ), " %varid% + %num% ,|)" , arrayInfo.varid ())) {
703693 const ArrayInfo ai (arrayInfo.limit (MathLib::toLongNumber (tok->strAt (4 ))));
704- checkFunctionParameter (*tok, 1 , ai, functionNames );
694+ checkFunctionParameter (*tok, 1 , ai);
705695 }
706696
707697 // goto 2nd parameter and check it..
@@ -714,10 +704,10 @@ void CheckBufferOverrun::checkFunctionCall(const Token *tok, const ArrayInfo &ar
714704 break ;
715705 if (tok2->str () == " ," ) {
716706 if (Token::Match (tok2, " , %varid% ,|)" , arrayInfo.varid ()))
717- checkFunctionParameter (*tok, 2 , arrayInfo, functionNames );
707+ checkFunctionParameter (*tok, 2 , arrayInfo);
718708 else if (Token::Match (tok2, " , %varid% + %num% ,|)" , arrayInfo.varid ())) {
719709 const ArrayInfo ai (arrayInfo.limit (MathLib::toLongNumber (tok2->strAt (3 ))));
720- checkFunctionParameter (*tok, 2 , ai, functionNames );
710+ checkFunctionParameter (*tok, 2 , ai);
721711 }
722712 break ;
723713 }
@@ -911,9 +901,9 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector<std::str
911901 // memset, memcmp, memcpy, strncpy, fgets..
912902 if (varid == 0 && size > 0 ) {
913903 if (Token::Match (tok, (" %var% ( " + varnames + " ," ).c_str ()))
914- checkFunctionParameter (*tok, 1 , arrayInfo, std::list<std::string>() );
904+ checkFunctionParameter (*tok, 1 , arrayInfo);
915905 if (Token::Match (tok, (" %var% ( %var% , " + varnames + " ," ).c_str ()))
916- checkFunctionParameter (*tok, 2 , arrayInfo, std::list<std::string>() );
906+ checkFunctionParameter (*tok, 2 , arrayInfo);
917907 }
918908
919909 // Loop..
@@ -985,8 +975,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const std::vector<std::str
985975 continue ;
986976
987977 const ArrayInfo arrayInfo1 (varid, varnames, total_size / size, size);
988- const std::list<std::string> functionNames;
989- checkFunctionCall (tok, arrayInfo1, functionNames);
978+ checkFunctionCall (tok, arrayInfo1);
990979 }
991980
992981 // undefined behaviour: result of pointer arithmetic is out of bounds
@@ -1110,7 +1099,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo
11101099
11111100 // Check function call..
11121101 if (Token::Match (tok, " %var% (" )) {
1113- checkFunctionCall (tok, arrayInfo, std::list<std::string>() );
1102+ checkFunctionCall (tok, arrayInfo);
11141103 }
11151104
11161105 if (Token::Match (tok, " strncpy|memcpy|memmove ( %varid% , %str% , %num% )" , arrayInfo.varid ())) {
0 commit comments