Fix uninitialized variable usage

This commit is contained in:
Daniel Marjamäki 2019-03-19 13:17:27 +01:00
parent a0e58f0039
commit 6cbe818f1a
1 changed files with 1 additions and 4 deletions

View File

@ -215,12 +215,11 @@ void CheckBufferOverrun::arrayIndex()
std::vector<Dimension> dimensions;
ErrorPath errorPath;
bool mightBeLarger;
bool mightBeLarger = false;
if (array->variable()->isArray() && !array->variable()->dimensions().empty()) {
dimensions = array->variable()->dimensions();
if (dimensions.size() >= 1 && (dimensions[0].num <= 1 || !dimensions[0].tok)) {
mightBeLarger = false;
visitAstNodes(tok->astOperand1(),
[&](const Token *child) {
if (child->originalName() == "->") {
@ -236,7 +235,6 @@ void CheckBufferOverrun::arrayIndex()
dim.num = Token::getStrSize(stringLiteral);
dim.known = array->hasKnownValue();
dimensions.emplace_back(dim);
mightBeLarger = false;
} else if (array->valueType() && array->valueType()->pointer >= 1 && array->valueType()->isIntegral()) {
const ValueFlow::Value *value = getBufferSizeValue(array);
if (!value)
@ -247,7 +245,6 @@ void CheckBufferOverrun::arrayIndex()
dim.tok = nullptr;
dim.num = value->intvalue / array->valueType()->typeSize(*mSettings);
dimensions.emplace_back(dim);
mightBeLarger = false;
}
if (dimensions.empty())