Merge pull request #634 from Dmitry-Me/avoidDeepCopy

Avoid deep copying std::string
This commit is contained in:
PKEuS 2015-08-07 19:38:38 +02:00
commit 48c6b30d1a
1 changed files with 4 additions and 5 deletions

View File

@ -526,7 +526,6 @@ void CheckIO::checkWrongPrintfScanfArguments()
const Token* argListTok = 0; // Points to first va_list argument
const Token* formatStringTok = 0; // Points to format string token
std::string formatString;
bool scan = false;
bool scanf_s = false;
@ -589,18 +588,18 @@ void CheckIO::checkWrongPrintfScanfArguments()
continue;
}
if (formatStringTok)
formatString = formatStringTok->str();
else
if (!formatStringTok)
continue;
const std::string& formatString = formatStringTok->str();
// Count format string parameters..
unsigned int numFormat = 0;
unsigned int numSecure = 0;
bool percent = false;
const Token* argListTok2 = argListTok;
std::set<unsigned int> parameterPositionsUsed;
for (std::string::iterator i = formatString.begin(); i != formatString.end(); ++i) {
for (std::string::const_iterator i = formatString.begin(); i != formatString.end(); ++i) {
if (*i == '%') {
percent = !percent;
} else if (percent && *i == '[') {