mirror of
https://github.com/Samsung/escargot.git
synced 2026-06-22 10:01:50 +00:00
When closing the iterator, handle exceptions that occur when retrieving the return function correctly.
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
parent
3f07b5696c
commit
ca7b289dd1
2 changed files with 16 additions and 10 deletions
|
|
@ -4955,19 +4955,28 @@ NEVER_INLINE void InterpreterSlowPath::iteratorOperation(ExecutionState& state,
|
|||
bool exceptionWasThrown = state.rareData()->controlFlowRecordVector() && state.rareData()->controlFlowRecordVector()->back() && state.rareData()->controlFlowRecordVector()->back()->reason() == ControlFlowRecord::NeedsThrow;
|
||||
IteratorRecord* iteratorRecord = registerFile[code->m_iteratorCloseData.m_iterRegisterIndex].asPointerValue()->asIteratorRecord();
|
||||
Object* iterator = iteratorRecord->m_iterator;
|
||||
Value returnFunction = iterator->get(state, ObjectPropertyName(state.context()->staticStrings().stringReturn)).value(state, iterator);
|
||||
if (returnFunction.isUndefined()) {
|
||||
Value returnFunction;
|
||||
Value innerResult;
|
||||
bool innerResultHasException = false;
|
||||
try {
|
||||
returnFunction = iterator->get(state, ObjectPropertyName(state.context()->staticStrings().stringReturn)).value(state, iterator);
|
||||
} catch (const Value& e) {
|
||||
innerResult = e;
|
||||
innerResultHasException = true;
|
||||
}
|
||||
|
||||
if (!innerResultHasException && returnFunction.isUndefined()) {
|
||||
ADD_PROGRAM_COUNTER(IteratorOperation);
|
||||
return;
|
||||
}
|
||||
|
||||
Value innerResult;
|
||||
bool innerResultHasException = false;
|
||||
try {
|
||||
innerResult = Object::call(state, returnFunction, iterator, 0, nullptr);
|
||||
} catch (const Value& e) {
|
||||
innerResult = e;
|
||||
innerResultHasException = true;
|
||||
if (!innerResultHasException) {
|
||||
try {
|
||||
innerResult = Object::call(state, returnFunction, iterator, 0, nullptr);
|
||||
} catch (const Value& e) {
|
||||
innerResult = e;
|
||||
innerResultHasException = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (exceptionWasThrown) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue