Merge pull request #256 from xypron/5505
5505: FP: Array accessed out of bounds
This commit is contained in:
commit
7fa73c0d64
|
@ -697,7 +697,7 @@ void CheckBufferOverrun::checkFunctionParameter(const Token &tok, unsigned int p
|
|||
|
||||
// Check the parameter usage in the function scope..
|
||||
for (const Token* ftok = func->functionScope->classStart; ftok != func->functionScope->classEnd; ftok = ftok->next()) {
|
||||
if (Token::Match(ftok, "if|for|while (")) {
|
||||
if (Token::Match(ftok, "if|for|switch|while (")) {
|
||||
// bailout if there is buffer usage..
|
||||
if (bailoutIfSwitch(ftok, parameter->declarationId())) {
|
||||
break;
|
||||
|
|
|
@ -2776,6 +2776,17 @@ private:
|
|||
" f(a);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f(int a[]) {\n"
|
||||
" switch (2) {\n"
|
||||
" case 1:\n"
|
||||
" a[1] = 1;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"int a[1];\n"
|
||||
"f(a);\n"
|
||||
"");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void possible_buffer_overrun_1() { // #3035
|
||||
|
|
Loading…
Reference in New Issue