Fixed #3931 (FP: Buffer access out-of-bounds)
This commit is contained in:
parent
358fb9a284
commit
8afdde0b5e
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue