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