Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion 3rdparty/libs/fileext/excel/formula.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,13 @@ void Formula::evaluateFormula(Name& name, int nameIndex, int level) {
hasRelation = (hasRelation || targetName.m_hasRelation);
}
else {
res = targetName.m_stack[0];
// 防御性检查:确保 stack 不为空
if (!targetName.m_stack.empty())
res = targetName.m_stack[0];
else {
res = Operand(oERR);
hasError = true;
}
}

res.m_rank = LEAF_RANK;
Expand Down Expand Up @@ -1021,6 +1027,12 @@ void Formula::evaluateFormula(Name& name, int nameIndex, int level) {
name.m_evaluated = true;
} catch (const std::exception &e) {
std::cout << e.what() << std::endl;
// 确保异常后 m_stack 不为空,避免后续访问崩溃
if (name.m_stack.empty()) {
name.m_stack.push_back(Operand(oERR));
}
name.m_hasError = true;
name.m_evaluated = true;
}
}

Expand Down