Fixed #3931 (FP: Buffer access out-of-bounds)

This commit is contained in:
Daniel Marjamäki 2012-08-12 17:06:54 +02:00
parent 358fb9a284
commit 8afdde0b5e
2 changed files with 6 additions and 2 deletions

View File

@ -279,6 +279,10 @@ static const Token *for_init(const Token *tok, unsigned int &varid, std::string
} else
return 0;
if (!init_value.empty() && (Token::Match(tok, "-- %varid%", varid) || Token::Match(tok, "%varid% --", varid))) {
init_value = MathLib::subtract(init_value, "1");
}
return tok;
}

View File

@ -1436,7 +1436,7 @@ private:
" buf[i] = 1;\n"
" }\n"
"}\n");
TODO_ASSERT_EQUALS("","[test.cpp:7]: (error) Buffer is accessed out of bounds: buf\n", errout.str());
ASSERT_EQUALS("", errout.str());
check("void f()\n"
"{\n"
@ -1446,7 +1446,7 @@ private:
" buf[i] = 2.;\n"
" }\n"
"}\n");
TODO_ASSERT_EQUALS("","[test.cpp:6]: (error) Buffer is accessed out of bounds: buf\n", errout.str());
ASSERT_EQUALS("", errout.str());
}
void array_index_multidim() {