Second fix for #4207 (Internal error. Token::Match called with varid 0)
This commit is contained in:
parent
c1d4a81795
commit
ec01cc811e
|
@ -605,8 +605,10 @@ void CheckBufferOverrun::checkFunctionParameter(const Token &tok, unsigned int p
|
|||
if (!parameter || _tokenizer->sizeOfType(parameter->typeStartToken()) != arrayInfo.element_size())
|
||||
return;
|
||||
|
||||
// Variable function arguments..
|
||||
if (Token::simpleMatch(parameter->typeStartToken(), ". . ."))
|
||||
// No variable id occur for instance when:
|
||||
// - Variable function arguments: "void f(...)"
|
||||
// - Unnamed parameter: "void f(char *)"
|
||||
if (parameter->varId() == 0)
|
||||
return;
|
||||
|
||||
// Check the parameter usage in the function scope..
|
||||
|
|
|
@ -1453,7 +1453,8 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void array_index_45() { // #4207 - handling of function with variable number of parameters
|
||||
void array_index_45() { // #4207 - handling of function with variable number of parameters / unnamed arguments
|
||||
// Variable number of arguments
|
||||
check("void f(const char *format, ...) {\n"
|
||||
" va_args args;\n"
|
||||
" va_start(args, format);\n"
|
||||
|
@ -1463,6 +1464,16 @@ private:
|
|||
" f(\"%s\", buffer);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// Unnamed argument
|
||||
check("void f(char *) {\n"
|
||||
" dostuff();\n"
|
||||
"}\n"
|
||||
"void test() {\n"
|
||||
" char buffer[1024];\n"
|
||||
" f(buffer);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void array_index_multidim() {
|
||||
|
|
Loading…
Reference in New Issue