Fixed #8597 (False positive - Array index is used before limits check.)
This commit is contained in:
parent
02eaf6fa93
commit
9ffb657c1a
|
@ -633,7 +633,7 @@ void CheckBufferOverrun::arrayIndexThenCheck()
|
||||||
// Iterate AST upwards
|
// Iterate AST upwards
|
||||||
const Token* tok2 = tok;
|
const Token* tok2 = tok;
|
||||||
const Token* tok3 = tok2;
|
const Token* tok3 = tok2;
|
||||||
while (tok2->astParent() && tok2->tokType() != Token::eLogicalOp) {
|
while (tok2->astParent() && tok2->tokType() != Token::eLogicalOp && tok2->str() != "?") {
|
||||||
tok3 = tok2;
|
tok3 = tok2;
|
||||||
tok2 = tok2->astParent();
|
tok2 = tok2->astParent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4099,6 +4099,11 @@ private:
|
||||||
" sizeof(a)/sizeof(a[i]) && i < 10;\n"
|
" sizeof(a)/sizeof(a[i]) && i < 10;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f(int i) {\n" // ?:
|
||||||
|
" if ((i < 10 ? buf[i] : 1) && (i < 5 ? buf[i] : 5)){}\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void bufferNotZeroTerminated() {
|
void bufferNotZeroTerminated() {
|
||||||
|
|
Loading…
Reference in New Issue