Fixed #1096 (Non-obvious error message: Overlapping data buffer)
This commit is contained in:
parent
72bf1c1dbe
commit
2e0566bf7a
|
@ -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)
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue