Fixed #5195 (Crash below CheckIO::checkWrongPrintfScanfArguments())

This commit is contained in:
Robert Reif 2013-11-23 08:40:35 +01:00 committed by Daniel Marjamäki
parent 8cca41774d
commit 0afdbc73da
2 changed files with 7 additions and 1 deletions

View File

@ -1407,7 +1407,7 @@ CheckIO::ArgumentInfo::ArgumentInfo(const Token * tok, const Settings *settings)
varTok = tok1->previous();
variableInfo = varTok->variable();
if (!isStdVectorOrString()) {
if (!variableInfo || !isStdVectorOrString()) {
variableInfo = 0;
typeToken = 0;
}

View File

@ -2098,6 +2098,12 @@ private:
ASSERT_EQUALS("[test.cpp:3]: (warning) %u in format string (no. 2) requires 'unsigned int' but the argument type is 'char'.\n"
"[test.cpp:3]: (warning) %f in format string (no. 3) requires 'double' but the argument type is 'char'.\n", errout.str());
// #5195 (segmentation fault)
check("void T::a(const std::vector<double>& vx) {\n"
" printf(\"%f\", vx.at(0));\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void testPosixPrintfScanfParameterPosition() { // #4900 - No support for parameters in format strings