Fixed #1096 (Non-obvious error message: Overlapping data buffer)

This commit is contained in:
Daniel Marjamäki 2009-12-21 21:05:55 +01:00
parent 72bf1c1dbe
commit 2e0566bf7a
2 changed files with 2 additions and 2 deletions

View File

@ -1643,7 +1643,7 @@ void CheckOther::dangerousUsageStrtolError(const Token *tok)
void CheckOther::sprintfOverlappingDataError(const Token *tok, const std::string &varname)
{
reportError(tok, Severity::error, "sprintfOverlappingData", "Overlapping data buffer " + varname + "\nWhen using sprintf the same buffer must not be used both for output and input. The behaviour is undefined when that happens.\nFor example: 'sprintf(str,\"<%s>\",str);'");
reportError(tok, Severity::error, "sprintfOverlappingData", "Undefined behaviour: " + varname + " is used wrong in call to sprintf or snprintf. Quote: If copying takes place between objects that overlap as a result of a call to sprintf() or snprintf(), the results are undefined.");
}
void CheckOther::udivError(const Token *tok)

View File

@ -346,7 +346,7 @@ private:
" char buf[100];\n"
" sprintf(buf,\"%s\",buf);\n"
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Overlapping data buffer buf\n", errout.str());
ASSERT_EQUALS("[test.cpp:4]: (error) Undefined behaviour: buf is used wrong in call to sprintf or snprintf. Quote: If copying takes place between objects that overlap as a result of a call to sprintf() or snprintf(), the results are undefined.\n", errout.str());
}
void sprintf2()