Fixed crash when array size variable has a value of zero
This commit is contained in:
parent
e82b607fa1
commit
6456a68805
@ -159,6 +159,11 @@ namespace hex::lang {
|
||||
return { nullptr, 0 };
|
||||
}
|
||||
|
||||
if (arraySize.value() == 0) {
|
||||
this->m_error = { varDeclNode->getLineNumber(), hex::format("Value of '%s' is zero", member->getArraySizeVariable().value().c_str()) };
|
||||
return { nullptr, 0 };
|
||||
}
|
||||
|
||||
ASTNodeVariableDecl *processedMember = new ASTNodeVariableDecl(member->getLineNumber(), member->getVariableType(), member->getVariableName(), member->getCustomVariableTypeName(), member->getOffset(), arraySize.value());
|
||||
|
||||
std::tie(pattern, memberSize) = this->createArrayPattern(processedMember, memberOffset);
|
||||
@ -220,8 +225,6 @@ namespace hex::lang {
|
||||
std::pair<PatternData*, size_t> Evaluator::createArrayPattern(ASTNodeVariableDecl *varDeclNode, u64 offset) {
|
||||
std::vector<PatternData*> entries;
|
||||
|
||||
auto arraySizeVariable = varDeclNode->getArraySizeVariable();
|
||||
|
||||
size_t arrayOffset = 0;
|
||||
std::optional<u32> arrayColor;
|
||||
for (u32 i = 0; i < varDeclNode->getArraySize(); i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user